I had following experience on my Nokia 6600 : my application needs around 1.7 MB of heap memory to run and consists of four modules that all allocate memory at different times. At startup, the first three modules allocate memory almost worth the 1.7 MB. At some stage in the program, module 3 frees its memory ( which is the biggest chunk, around 1 MB ) and then allocates again. Also, module 4 allocates memory but runs out of it, although it needs not much. Modules 1 and 2 stay untouched all the time.
What puzzles me a bit, is that the overall memory consumption in the startup situation is higher than later in the program and there it does not run out of memory.
So far, I don't feel desperate about this problem, yet. My guess is that the cause is some memory fragmentation. Anyone have an idea?
Also, does anyone know how memory is allocated ( always seqential chunks, beginning at "lowest" address? ) ?
Also, is it possible to defragment the heap during runtime? I heard something like this but don't know.
thanks for your reply. I tried to simulate the situation on the EPOC emulator by decreasing the MB of free mem in the .ini file. Then I played with the "User::Available" function but strangely it always told me the same amount of free memory, no matter what MB I entered in the .ini file...? What's this?
By now, I think the reason is some bug in my program because I found out that my 6600 has huge heap memory... I wrote another post about it in the "Devices/Phones" section of this forum, "General Discussion". Maybe you can help me there, too.
I think what's really important is to look at the biggest available memory block (User::Available(biggest)). You can have lots of free memory, but if it is fragmented it is not of much use if you try to allocate a lot of mem at once.