Page 1 of 1
String/array memory usage
Posted: Thu Oct 27, 2011 7:04 am
by jesperbrannmark
Hi.
This might seem like an odd request because normally this is stuff you should keep track off while developing...
But my program just recently went from 2 MB RAM usage to 90 MB. On a modern PC that is not noticed, but on a five year old that really affects the user experience.
So my question is:
Is there a easy way to list all arrays/maps/lists used and see their memory usage so I can see which one is taking up all that memory?
Re: String/array memory usage
Posted: Thu Oct 27, 2011 7:20 am
by citystate
put in a breakpoint and use the variable viewer? (I think it gives some info on lists and arrays, so I guess it might do maps too)
Re: String/array memory usage
Posted: Thu Oct 27, 2011 11:49 am
by infratec
Hi,
add a keyboard shortcut and than build a Text$ with the help of ArraySize() ListSize() and MapSize()
and at least use MessageRequester() to show the values.
Bernd
Re: String/array memory usage
Posted: Thu Oct 27, 2011 1:12 pm
by jesperbrannmark
I see my problem is in a array (probably) like one of those
With the ones that are integer, long etc i have no problem figuring out the size of them, but with strings - is there a smart way?
Re: String/array memory usage
Posted: Thu Oct 27, 2011 1:30 pm
by Shield
You need to iterate through the array and sum up the length of each string. Also don't forget to add the memory required for the pointers
to actually reference the strings.

I don't think there is any other way.
Re: String/array memory usage
Posted: Thu Oct 27, 2011 2:01 pm
by RASHAD
For Windows
1- Include the next code into a Procedure
2- Call the Procedure after each use of ( Arrary,LinkedList,Map,.... )
3- Write the result to a Log File
You can get the memory hungry act from the log
Code: Select all
Memory.MEMORYSTATUSEX
Memory\dwLength.l = SizeOf (Memory)
GlobalMemoryStatusEx_(Memory.MEMORYSTATUSEX)
Debug "Available Physical Installed : "+Str(Memory\ullAvailPhys.q /1024/1024) + " MB"
Debug "Free of Paging File : "+Str(Memory\ullAvailPageFile.q/1000000)