1. ## How can I see how many bytes an array need?
Is it like this:
Dim MyArr(999,999,1) as string
In the first dimension are there 1000 places(0->999), in the second also 1000, and in the third are there 2 places, so: 1000*1000*2=2000000 bytes =2MB?

Am I right? Tell me

WP  Reply With Quote

2. Thats basically 2 million *elements* in your array. Then you have to multiply that by the space that each string takes up. Since it is variable length strings that you are storing, this amount of space also varies...

i'm not sure of the exact specs, but basically if all your strings averaged, say, 50 bytes (characters), then you get 2Mb * 50 = 100Mb

whichever way its alot of space...

hope this helps a bit..  Reply With Quote

3. ## 100 MB RAM?

Thank you, but for easy working, does the user need 100MB RAM?

WP  Reply With Quote

4. each variable length string is 10 bytes + length of string * 2
each dimension in an array needs 2 bytes for descriptor, that makes the length:
10*1000*1000*2+2+2+2+2X = 20 000 000 + 2X
that is that it automatically takes up 20MB RAM + 2*the amount of space all the strings takes up  Reply With Quote

5. WP,

may i ask what sort of application requires 2 million strings? just curious...  Reply With Quote

6. ## 2X ?

Oh, its just an example, i wanted to know how i can count the needed bytes (i'm not using this big array)

But Kedaman,
+ 2*the amount of space all the strings takes up
What exactly do you mean, its 20MB RAM + ? thanks WP  Reply With Quote

7. ## Re: 2X ?

Originally posted by WP
But Kedaman,
+ 2*the amount of space all the strings takes up
What exactly do you mean, its 20MB RAM + ? [/B]
What he means is that, say you have a string that contains:

"Hi there WP", that takes up 11 bytes (since 11 characters), then the length of the string is 11, and according to kedaman it takes up 10 + 2*11 bytes.

so if you have 2 million strings each of length 11, then "the amount of space all the strings takes up" will be 2 million times 11.

so the complete grand total figure for the amount of memory it would take up would be:

20MB + 2 * ( 2,000,000 * 11) = 64MB RAM total.  Reply With Quote

8. Thats correct funky, strings are unicode by default in vb, that means each character takes up 2 bytes. You could reduce the amount of space by converting from unicode into a byte array for instance:
Dim a() as byte
A=strconv("THIS TAKES UP 44 BYTES",vbfromunicode)  Reply With Quote

9. ## Thanks

Thanks a lot, all of you. Now I can avoid the "out of memory" error cause I can calculate the needed RAM.

WP   Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•