Page 1 of 1

HELP:Memory allocation problem

PostPosted: May 4, 2004 @ 3:42pm
by pacomac
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?

PostPosted: May 4, 2004 @ 5:38pm
by tomdon

PostPosted: May 4, 2004 @ 7:34pm
by sponge

PostPosted: May 4, 2004 @ 8:37pm
by refractor

PostPosted: May 4, 2004 @ 10:04pm
by joshbu [MSFT]

PostPosted: May 5, 2004 @ 9:28am
by pacomac

PostPosted: May 5, 2004 @ 9:31am
by pacomac