OOM component, OutOfMemoryException

D

Daniel Moth

Hi

I have been experiencing the OOM dialog that CE throws up so I am trying to
diagnose where the leak in my app is (assuming there is one)...

The dialog pops up with the caption "Program Memory is Low". Then there are
options to close a form down or "Convert some Storage Memory to Program
Memory...". I understand this is the OOM component... I would like to handle
this situation in my code rather than have the OS do it not only because
that dialog actually goes beyond our (240x320) screen but because I would
rather reset the unit (or restart the app) if a GC.Collect doesn't help at
that point...

So the questions are:

1. Has anybody else done this before? I understand that I will have remove
the OOM component and then call SetOOMEvent (just changing the registry
values had no effect)... I think I'll pass it a handle and 0s for the
remaining 4 values.. Anybody see a problem with that?

2. Shouldn't I get an OutOfMemoryException when the low memory condition
occurs? Replicating a low memory condition (using the memory slider) always
results in the OOM dialog coming up and never an OutOfMemoryException. Could
it be a case of the dialog popping up before the GC has a chance to collect
the garbage?

Cheers
Daniel

PS This is with CF 1.0 SP2 on own CE 4.2-based device
 
D

Daniel Moth

Just to add to my original questions...

3. Since others have seen the OutOfMemoryException and I am seeing the OOM
dialog, does anybody know the difference between the two?

Here is the relevant link for the OOM component (contains link to the
SetOomEvent API)
http://msdn.microsoft.com/library/d...n40/html/cmconoomthresholdmigrationissues.asp

Here is the link for the OOM managed exception (there is even a .NETcf
Platform Note)
http://msdn.microsoft.com/library/d...frlrfsystemoutofmemoryexceptionclasstopic.asp

Cheers
Daniel
 
D

Daniel Moth

Since my last post and after numerous tests I have occassionally observed
the managed OutOfMemoryException rather than the OS OOM dialog (!) during
identical test case scenarios. This seems very random and if I had to give a
statistic I'd say 1 out of 50 times you'll get the exception isntead of the
dialog... Somebody must know the difference between when one is shown
instead of the other so please enlighten us... or is it random in reality?

In case anybody thinks this is academic research it isn't. I have a real app
that suffers from the OOM dialog (never an OutOfMemoryException) when in
reality there is no apparent memory leak in the app... I am trying to narrow
this down to a small reproducable case...

Cheers
Daniel
 
D

Daniel Moth

Removing the OOM component from the image fixes this (without a need to call
SetOomEvent)... i.e. without the OOM component, when the app uses more
memory than what it should, we see the OutOfMemoryException... Shame the CLR
does not have a tighter cooperation with the OOM component...

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top