NETCF app and "Program memory low" dialog

333 Views Asked by At

I have a memory leak somewhere in my NETCF app, but instead of getting the "OutOfMemoryException" with the nice stack trace to track it down, I get the big white wince "Program memory..." dialog and have to restart the device. Can anyone give me or point me to a good set of directions to disable the "Program memory" dialog, and have the OutOfMemoryException be raised instead?

It was suggested that I replace the "UI based notification" component in my OS Design with the "Non UI based notification" one, but that won't work for me because admin users need to be able to use the WinCE shell, which has a dependency on the "UI based notification" component.

1

There are 1 best solutions below

0
On

A possible work-around would be to monitor the memory usage manually. You can use the native API GlobalMemoryStatus() to obtain the current memory load (percentage of system memory in use). It will not help if you get a sudden spike in memory usage, but if it is a slow leak you should be able to catch it before the system hangs with memory dialog. We have used it in this way to ensure that the device would automatically log the error and restart if it ever occurred.