Re: Memory Leak due to objects not destroyed



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
> >
>
>
>
.



Relevant Pages

  • Re: FuncA to call FuncB, passing newParam1 AND allParamsPassedIntoFuncA
    ... I understand your concern over the design Michael, ... This will create the attribute, register the event, and all is well... ... Opera, etc.) to my handler, BUT, also, also pass it along to IE (cause it is plain anoying to have to retrieve it inside every single event handler on my page, if I can pass it instead) ...
    (comp.lang.javascript)
  • Re: FuncA to call FuncB, passing newParam1 AND allParamsPassedIntoFuncA
    ... I understand your concern over the design Michael, ... This will create the attribute, register the event, and all is well... ... registration" call, to register the events in Moz, Opera, IE, etc. ... arguments passed to my "event handler wrapper"... ...
    (comp.lang.javascript)
  • RE: Triggering Events on <asp: RadioButton Help.
    ... you register the ItemCreated event handler in the ... > block so that register it evetytime the page is request. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Subscriber callback interface design
    ... > EventHandlerInterface and change RegisterEvent/UnregisterEvent to accept ... One thing you might want to consider is allowing clients to register ... event handler functors rather than event handler objects. ...
    (comp.lang.cpp)
  • HTMViewer Memory Leak
    ... the HTML viewer provided now for free by www.pbear.com for viewing of HTML documents seems to have a memory leak in the image reading code. ... The var parameter indicates that the stream has to be created by the event handler. ... FastMM, correspondingly, complains about a memory leak. ...
    (borland.public.delphi.thirdpartytools.general)