all groups > dotnet compact framework > november 2005 >
You're in the

dotnet compact framework

group:

OutOfMemeoryException



OutOfMemeoryException Tom Robson
11/14/2005 10:58:03 PM
dotnet compact framework: I have a Pocket PC app that is coming up with a outofmemory exception.
Bacially it loads a big document and everything is enclosed in a big object
that gets mouse events and paint events from a panel. I also use one global
form and reuse this all the time to display a set of forms all defined in the
big document. There is no unmanaged code, no multithreading, and it is all
pretty basic .NET stuff.

When I set the big object to nothing (getting rid of all the references and
event hook ups), and dispose of the form (because they normally hold some odd
references to things) and run a GC.Collect(), I expected the GC to be able to
collect everything. My understanding from hours reading about the GC is that
it collects everything that hasnt got a reference from the roots.

Why therefore do I lose about 1Mb each time I open and close one of these
big documents. I guess thats too hard - lets rephrase.
Do I need to 'manually' dispose of everything with a dispose option?
Is there something better than ce remote heap walker (whichy doesnt work
here probably because it is too big) for debugging?
Is dumping a whole set of stuff acceptable practice, seams very neat to me?
Could the Form somehow retain a reference to some of the controls that are
since moved from it, even after disposal?

Re: OutOfMemeoryException ctacke/
11/15/2005 7:28:06 AM
Ore you running CF 1.0 RTM or a service pack? In your OnPaint override, do
you Dispose your GDI objects?

-Chris





[quoted text, click to view]

Re: OutOfMemeoryException Tom Robson
11/16/2005 6:56:03 PM
Since my last post,I have set up a whole chain of disposes, to get rid of
some controls that I create and this atleaast on intial inspection seams aid
in the release. I would still like a clear description of when dispose is and
isnt required. Some articles suggest dont bother, some suggest always use
when available. Confusing


[quoted text, click to view]
Re: OutOfMemeoryException Chris Tacke, eMVP
11/17/2005 12:36:32 PM
As a general rule, if a class explicitly implements Dispose, you should call
it.

--
Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF? Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate


[quoted text, click to view]

AddThis Social Bookmark Button