Dear Greats,

We are working on Windows CE 5.0 Operating system, Explorer template.
(AMD Au1200, Board Support Package) is used.

We have written one simple application

main()
{


char * strTemp = new char[10];

getch()

delete [] strTemp

}

The problem we are observing is, After 'new" two heaps of 4K is
created (This we have monitored in using Entrek ProcMan tool).

One 4K heap has 16 bytes are allocated and left are shown as free
space. After "delete", one of the 4K heap is deleted but the
additional heap created is not deleted.

Kindly any one of you can guide us on solving this problme. because of
this the system memory is growing up and ending in a crash.

Can we use HeapCompact call to clear up this process memor? Can run a
separate thread in Windows CE OS to clearing the memory marked for
deletion.

With regards,
Mams

Re: Windows CE memory release by Paul

Paul
Wed Apr 11 10:23:34 CDT 2007

No, that can't be the cause of your crash. When you do the new[], the
run-time library is setting up a heap to allocate your C++ allocations from.
You don't expect that to ever go away until the program exits. The next
time you do another new[], it won't create another heap.

Paul T.

"Mams" <avk_spy@yahoo.com> wrote in message
news:1176299420.287255.228160@n76g2000hsh.googlegroups.com...
> Dear Greats,
>
> We are working on Windows CE 5.0 Operating system, Explorer template.
> (AMD Au1200, Board Support Package) is used.
>
> We have written one simple application
>
> main()
> {
>
>
> char * strTemp = new char[10];
>
> getch()
>
> delete [] strTemp
>
> }
>
> The problem we are observing is, After 'new" two heaps of 4K is
> created (This we have monitored in using Entrek ProcMan tool).
>
> One 4K heap has 16 bytes are allocated and left are shown as free
> space. After "delete", one of the 4K heap is deleted but the
> additional heap created is not deleted.
>
> Kindly any one of you can guide us on solving this problme. because of
> this the system memory is growing up and ending in a crash.
>
> Can we use HeapCompact call to clear up this process memor? Can run a
> separate thread in Windows CE OS to clearing the memory marked for
> deletion.
>
> With regards,
> Mams
>



Re: Windows CE memory release by Mams

Mams
Wed Apr 11 23:14:35 CDT 2007

Hai,

Thanks, but why the OS is not releasing this memory. In our OS setup,
application deletes all the memory created, we are confirming this
with the codesnitch tool. But still the free memory available in the
system is not reducing. When we look in the heap walker we are able to
see the heap contents that are deleted are present still in the
memory.

Can we use HeapCompact API to clear all the memory that are marked for
deletion periodically, Before the Operating system clears up the
memory.

With regards,
Mams


Re: Windows CE memory release by Paul

Paul
Thu Apr 12 11:28:11 CDT 2007

It's not releasing the application heap when you exit?! Sorry, but I can't
believe that's true.

If you are saying that the heap size does not decrease *while the
application is still running*, yes, I believe that. You can call
HeapCompact(), but you'll have to figure out what to call it on.

Here's a good thread from the archives about avoiding fragmentation and
conserving your heap sizes:

http://groups.google.com/group/microsoft.public.windowsce.embedded.vc/browse_thread/thread/622d482281469707/ac45617cadec7a8e?lnk=st&q=&rnum=5&hl=en#ac45617cadec7a8e

Paul T.

"Mams" <avk_spy@yahoo.com> wrote in message
news:1176351275.771927.233450@w1g2000hsg.googlegroups.com...
> Hai,
>
> Thanks, but why the OS is not releasing this memory. In our OS setup,
> application deletes all the memory created, we are confirming this
> with the codesnitch tool. But still the free memory available in the
> system is not reducing. When we look in the heap walker we are able to
> see the heap contents that are deleted are present still in the
> memory.
>
> Can we use HeapCompact API to clear all the memory that are marked for
> deletion periodically, Before the Operating system clears up the
> memory.
>
> With regards,
> Mams
>



Re: Windows CE memory release by Mams

Mams
Fri Apr 13 06:43:39 CDT 2007

Thanks Paul,

I geatly appreciate your help. We will try to create separate heap to
avoid any fragmentation.

I like to make sure, that my application written is not producing any
leak.

My application starts create and delete one object (gSOAP object) we
are using

1. On creation of the object the memory increased
2. On deletion, the memory remains same

This loop, I tried to run for multiple times. At one point of time
(within 100 loops) we noticed that around 8 K of available system
memory is reduced. Then I called HeapCompact. it restored 4 K of
memory, But still another 4K is out.

Using Windows CE Platform builder HeapWalker, I have taken the snap
shot of all the process (device, filesys, explorer, myapplication,
cemgrc) at the initial stage and compared with the current staage
(after this 4K leak) snap shot. No process has consumed 4K.

I am confused, where the memory is blocked. Is this because of the
heap fragmentation. Kindly confirm this, we are looking on two aspects
(Application and Operating system)

With regards,
Mams


Re: Windows CE memory release by Paul

Paul
Fri Apr 13 11:05:46 CDT 2007

> My application starts create and delete one object (gSOAP object) we
> are using
>
> 1. On creation of the object the memory increased
> 2. On deletion, the memory remains same

Yes, I'd say that this is expected. Over time, if the run-time library heap
starts to fill up, at some point it should automatically try to compact the
heap, but no one really knows what the triggering condition for that is or
why it might not be working in your case. The single allocation test means
absolutely nothing, however. That doesn't tell you anything useful at all
about memory allocations.

> This loop, I tried to run for multiple times. At one point of time
> (within 100 loops) we noticed that around 8 K of available system
> memory is reduced. Then I called HeapCompact. it restored 4 K of
> memory, But still another 4K is out.

I did the same an got approximately the same result. I don't see a problem
with it.

> Using Windows CE Platform builder HeapWalker, I have taken the snap
> shot of all the process (device, filesys, explorer, myapplication,
> cemgrc) at the initial stage and compared with the current staage
> (after this 4K leak) snap shot. No process has consumed 4K.

It's not a leak unless it's repeated when you do another allocation, taking
up 4K more memory each time. Call it "overhead".

Paul T.



Re: Windows CE memory release by Mams

Mams
Wed Apr 25 00:22:49 CDT 2007

Thanks Paul,

Now I understand the functionality.