Restored from previous forum. Originally posted by PB.
I don't anything about how the Dim command works, with regard to memory use,
so can someone please explain this for me: If I have these three lines of code,
how much memory is used by declaring them? Any memory, or are they not used
until their contents are actually filled with variables?
Dim one$(999)
Dim two$(999)
Dim three$(999)
PB - Registered PureBasic Coder
How does Dim work?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
However, your basic array (4 bytes for a string pointer * 1000 elements) will be allocated as soon as you call the Dim command. AFAIK PB does not support dynamic arrays, unless you manually code that.
For a string array, each pointer will be NULL to start with and then memory is allocated for the string when you assign it a value.
I'm sure there's a 3rd party lib which has commands for getting the amount of free memory - you could always open a console window and print the free memory as you go.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
Arrays of strings are a bit different since you not only have the array memory, you have the string memory.I don't anything about how the Dim command works, with regard to memory use,
so can someone please explain this for me: If I have these three lines of code,
how much memory is used by declaring them? Any memory, or are they not used
until their contents are actually filled with variables?
Dim one$(999)
Dim two$(999)
Dim three$(999)
However, your basic array (4 bytes for a string pointer * 1000 elements) will be allocated as soon as you call the Dim command. AFAIK PB does not support dynamic arrays, unless you manually code that.
For a string array, each pointer will be NULL to start with and then memory is allocated for the string when you assign it a value.
I'm sure there's a 3rd party lib which has commands for getting the amount of free memory - you could always open a console window and print the free memory as you go.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.