Memory/Array Limits

Z80CPU

Member
Licensed User
hello!

my questions are, arrays, what are the limits?

for example, in vb6, i could use:

dim a(1024000)

with no problem, however, when i did a much smaller size in B4A, it died/puked/did not work/etc.

what are the limit(s)? is it based on the OS memory? B4A? both?



if it is based on memory, is there any 'trick' to see how much ram could be used without using all available free ram? i am aware of the 'os library'...
in vb, if i used up all RAM, then it would start using the swap file till the HDD was full.




another question on this is, does B4A 'add' the memory used like most languages do? for example, in basic/vb:

dim a(100,3) = 100 * 3 = total memory used = 300 bytes

i am asking about 'general' variables, not the 'fancy' ones... ;)




are the string varis length 'fixed'? example:

vb: a="1234567890qazwsxwedc3216549879876543216549874321684321654"
in some languages, the length is fixed, 'basic for dos/quick basic/etc' is if i remember correctly, and in vb it is not (basically)



also (as a silly question), does android even use a 'swap file' for
memory?


if it does, is it used the same way as windows does?
if it does, can it be deleted as you can in windows (at certain times)?
if it does, where is it typically stored/name of file?


thank you for who ever answers these questions!

ken
:)
 
Last edited:

Erel

Administrator
Staff member
Licensed User
dim a(1024000)

with no problem, however, when i did a much smaller size in B4A, it died/puked/did not work/etc.

what are the limit(s)? is it based on the OS memory? B4A? both?
The only limit is the process available memory.

Did you get an out of memory error? It is not a large array. There is no reason for this to happen.

another question on this is, does B4A 'add' the memory used like most languages do? for example, in basic/vb:
Not sure that I understand. When you declare an array the memory is allocated based on the array size.

are the string varis length 'fixed'?
No.

also (as a silly question), does android even use a 'swap file' for
memory?
The underlying OS does support swap files. I believe that most devices (or all) do not use a swap file.
The memory available for each process is usually quite small. About 32mb.
 
Upvote 0

Z80CPU

Member
Licensed User
Re: Array/Memory

hello Erel,

thank you for your reply.

as far as the 'out of memory' error, i cannot remember the exact error except it was a string and 'arrayed' as (x,y,z). that is about all i can remember. it could be the android emulator's RAM was too small... ;)

the array size, some languages use a 'dynamic' array. it only grows as it is used. so if i create an array (200,2) some languages would right away 'reserve' 400 bytes. Others would not. and if i used that array to store only 2 bytes, then the array (in memory) would ONLY consume 2 bytes. you see this 'trick' done also with virtual HDD's on VM software.

thank you very much for the quick and prompt answer! your help and answers are always 'spot on' and i am always thankful for your help!

:)
 
Upvote 0
Top