How can it survive Windows Mobile memory management?

Mar 26, 2009 at 11:08 AM
Thank you for your work! But can you tell me how it survive Windows Mobile memory management? I can't find a answer in your website.
Mar 26, 2009 at 1:07 PM
Hi,

when you look at the Sourcecode, you will discover an infinite loop, which is fetching Windows Messages.
This is why the app / service doesn't get garbage collected. It is a similar mechanism to Windows Forms apps, which don't get collected as well until Application.Exit() is called.

I hope this helps.

Cheers, Peter
Mar 26, 2009 at 4:37 PM
Thank you! I saw the endless loop before my queston. I don't understand why it doesn't show in "Running Programs List"? That is , why it can treat the process manager?  Thank again.
Mar 26, 2009 at 5:33 PM
There is more stuff going on underneath, when you use Application.Run(), so that you can see the application within the Progams Task List. When you have a simple Console Application running on your WM device, you don't see it there as well.

That's the explanation.
Mar 27, 2009 at 5:08 AM
Thank you very much! You lighten me.
Mar 27, 2010 at 12:51 PM

Memory Management on Windows Mobile devices and .NET Garbage Collection are two very different things.

when you look at the Sourcecode, you will discover an infinite loop, which is fetching Windows Messages.
This is why the app / service doesn't get garbage collected.

I believe that this service implementation is capable of surviving memory management due to the fact that it does not handle WM_HIBERNATE or WM_CLOSE messages sent from the OS during memory management.

It is a similar mechanism to Windows Forms apps, which don't get collected as well until Application.Exit() is called.

It is actually in direct contrast with a Compact Framework Windows Forms application which does handle WM_HIBERNATE and WM_CLOSE messages and is subject to being suspended and/or terminated by the OS during memory management.