Re: Memory Leak due to objects not destroyed
- From: Guillaume C. (France) <Guillaume C. (France)@discussions.microsoft.com>
- Date: Fri, 29 Apr 2005 06:36:03 -0700
Thanks for this thought !
I checked and there was no direct event handler on a long lived object.
I have done one thing to try : I unregistered all events registered by my
code when Dispose is called.
The result is not bad (even if not really good for my memory leak) : the
form is now well destroyed, but it does not have a real influence on the
memory leak (after 20 loops of a 4 forms, no significant difference ).
So events management seems to be one cause for objects not to be collected.
I will try to go further in this side.
Is there a way to remove all registered event handlers on an object (like a
DataTable to take a sample) ?
"Stelrad Doulton" wrote:
> just a quick thought....... does the problematic form register an event
> handler on a long lived object?
>
>
> "Alex Feinman [MVP]" <public_news@xxxxxxxxxxxxxxx> wrote in message
> news:uWpQwOCTFHA.3376@xxxxxxxxxxxxxxxxxxxxxxx
> > That form you mention, can you confirm that it's Dispose method is indeed
> > called? Do you perform any cleanup in it? Are there any references to it
> > in other parts of the applications (look for collections)?
> >
> > --
> > Alex Feinman
> > ---
> > Visit http://www.opennetcf.org
> > "Guillaume C. (France)" <Guillaume C. (France)@discussions.microsoft.com>
> > wrote in message
> > news:D0BEF179-B043-4FCE-8E9F-DA60CFECC853@xxxxxxxxxxxxxxxx
> >> Hi everybody!
> >> we developped an .NET CF application, and we experience a memory leak at
> >> runtime which continues until having a out of memory. I work on it since
> >> a
> >> few days, i've been googling a lot to see similar problems, but nothing
> >> helped me.
> >>
> >> The problem is in fact simple : I have some objects that are never
> >> destroyed
> >> nor collected, and i really don't understand why. There is quite a great
> >> number of forms (for an embedded app), about 50 (with a maximum of 5
> >> instanciated at a time), we developped. I logged calls to constructs and
> >> destructors for the forms and some other important objects of the
> >> application. it appears that most forms
> >> are well collected at runtime. But I have one (for what i know) that is
> >> nether destroyed till we exit app. And it seems to be the same for a
> >> number
> >> of objects, some of them beeing quite large objects with datatables.
> >> Worst for the form, It can be called in various part of the app, and
> >> there
> >> are calls that make the form collected. And the calls are always the
> >> same,
> >> something like this :
> >> using (Form myForm = new Form)
> >> {
> >> myForm.ShowDialog();
> >> // Some code using returns of myForm
> >> }
> >>
> >> For all that i saw, and i looked for, there are no reference keeped on
> >> the
> >> form, neither on the other objects i've found they're not collected.
> >>
> >> I'm sure Garbage collection is made cause i logged memory usage
> >> (GC.GetTotalMemory) and there are fluctuations (and as we are other 1Mo
> >> of
> >> used RAM, it must be called very often if i understand).
> >>
> >> I've succeeded in slowing down memory leak by overriding Dispose(bool
> >> disposing) method in all our forms so that they set all referenced
> >> objects
> >> specifics to the form in it to null, but it was not enough and it results
> >> only a more linear curve.
> >>
> >> There possibly always are reference(s) to uncollected objects, but i
> >> don't
> >> know where, and i don't know any meaning to get the information.
> >>
> >> Does anyone have some info that could help (a known issue of CF 1.0 SP3,
> >> tools to help me found references, anything else...) ?
> >>
> >> If you need more info, i can try to give you some. I would have prefered
> >> being able to isolate the problem, but it seems to me it's a lot of work.
> >>
> >> Thanks to anyone who can help ;).
> >>
> >> Guillaume
> >
>
>
>
.
- References:
- Memory Leak due to objects not destroyed
- From: Guillaume C. (France)
- Re: Memory Leak due to objects not destroyed
- From: Alex Feinman [MVP]
- Re: Memory Leak due to objects not destroyed
- From: Stelrad Doulton
- Memory Leak due to objects not destroyed
- Prev by Date: Re: Does CompactFramework function in PC based Windows environment?
- Next by Date: Re: Bluetooth
- Previous by thread: Re: Memory Leak due to objects not destroyed
- Next by thread: Re: Memory Leak due to objects not destroyed
- Index(es):
Relevant Pages
|