|
-
Nov 2nd, 2000, 07:02 AM
#1
Thread Starter
Hyperactive Member
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
-
Nov 2nd, 2000, 07:11 AM
#2
Addicted Member
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..
-
Nov 2nd, 2000, 07:20 AM
#3
Thread Starter
Hyperactive Member
100 MB RAM?
Thank you, but for easy working, does the user need 100MB RAM?
WP
-
Nov 2nd, 2000, 08:06 AM
#4
transcendental analytic
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
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 2nd, 2000, 08:59 AM
#5
Addicted Member
WP,
may i ask what sort of application requires 2 million strings? just curious...
-
Nov 2nd, 2000, 10:16 AM
#6
Thread Starter
Hyperactive Member
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
-
Nov 2nd, 2000, 10:28 AM
#7
Addicted Member
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.
-
Nov 2nd, 2000, 11:48 AM
#8
transcendental analytic
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)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 2nd, 2000, 12:32 PM
#9
Thread Starter
Hyperactive Member
Thanks
Thanks a lot, all of you. Now I can avoid the "out of memory" error cause I can calculate the needed RAM.
WP
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|