I have a strange memory allocation problem which is driving me nuts. I load large images into a tile cache for fast access. I store my image in multiple blocks of memory returned by malloc(). When I later free off the memory I don't seem to get it back again. I am using GlobalMemoryStatus to give me an idea of how much memory is available but it appears that either free() is not working or because of fragmentation free physial memory is being misreported.
The following lines allocate 24 blocks of 64K then immediately free them...
for(i=0; i<24; i++) Ptr[i] = (UINT *)malloc(1024 * 64);
for(i=0; i<24; i++) free(Ptr[i]);
the result should be no change in free physical memory as I've de-allocated all 24 blocks... Unfortunately GlobalMemoryStatus does not reflect this. :?
If I change the allocated block size to 128K eveything works fine.
Anybody any ideas.... is there a way to compact/defragment memory?