This site is no longer active and is available for archival purposes only. Registration and login is disabled.

HELP:Memory allocation problem


HELP:Memory allocation problem

Postby pacomac » May 4, 2004 @ 3:42pm

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?
pacomac
pm Member
 
Posts: 22
Joined: Sep 22, 2003 @ 2:39pm


Postby tomdon » May 4, 2004 @ 5:38pm

Image
User avatar
tomdon
pm Insider
 
Posts: 1605
Joined: Jan 12, 2003 @ 8:46pm
Location: Isle of Wight - United Kingdom


Postby sponge » May 4, 2004 @ 7:34pm

holy internets batman.
User avatar
sponge
Not sponge
 
Posts: 12779
Joined: Jan 13, 2002 @ 8:04am
Location: New Hampshire


Postby refractor » May 4, 2004 @ 8:37pm

User avatar
refractor
pm Insider
 
Posts: 2304
Joined: Feb 5, 2002 @ 1:12pm
Location: Luxembourg


Postby joshbu [MSFT] » May 4, 2004 @ 10:04pm

joshbu AT microsoft dot-you-know-where
Windows CE Software Design Engineer

“This posting is provided “AS IS” with no warranties, and confers no rights.”
joshbu [MSFT]
pm Member
 
Posts: 60
Joined: Apr 10, 2004 @ 12:28am
Location: Redmond, WA


Postby pacomac » May 5, 2004 @ 9:28am

pacomac
pm Member
 
Posts: 22
Joined: Sep 22, 2003 @ 2:39pm


Postby pacomac » May 5, 2004 @ 9:31am

pacomac
pm Member
 
Posts: 22
Joined: Sep 22, 2003 @ 2:39pm


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum