Re: StatusStrip control leaks its collection items

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Thu, 10 Jul 2008 13:55:31 -0700, <carl.clawson@xxxxxxxxxxxxx> wrote:

On Jul 10, 12:52 pm, Family Tree Mike
<FamilyTreeM...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
It would seem to make sense that you would have issues if you don't dispose
something that can be disposed.

I don't expect to have to dispose things explicitly unless there's a
reason that I need to have it done at a specific point in the code.
That's what the garbage collector is for.

This is categorically WRONG.

Jack's reply addresses this, but because it's so important, let me be very clear: if an object implements IDisposable, it's _essential_ that you call Dispose() on the object when you're done with it. The garbage collector is for releasing _managed_ memory. _Disposing_ objects is the exact opposite of "what the garbage collector is for".

Pete
.



Relevant Pages

  • Re: Need explanation on calling Close() from finalizer.
    ... understand is why .NET classes cannot clean up their unmanaged resources ... > NET's Garbage Collector, like you've stated, automated memory management, ... > the Dispose pattern. ... >>> hoping your finalizer will someday be called when the garbage collector ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: events and object lifetime
    ... onto the objects with a direct reference and had a method to set the ... Whether you use Dispose() or some other method name, ... hanging around until your application terminates and a "true" memory ... garbage collector and concentrate on programming your application. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: StatusStrip control leaks its collection items
    ... That's what the garbage collector is for. ... Dispose() on the object when you're done with it. ... WHEN the unmanaged resources get released, or if you need to force ... The finalizer will eventually take care of it as long as ...
    (microsoft.public.dotnet.framework)
  • Re: How to clear controls from a form - Help Needed
    ... some other links I got the impresion that including a dispose method in your ... class modules actually was not needed unless you had some unmanaged resources ... An object that implements Dispose often also implements a Finalizer. ... Finalizer is code that runs when the garbage collector frees the ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Get rid of DataTable
    ... Set it to null + call Dispose on it? ... The garbage collector registers with Windows for low-memory conditions, and will, when needed, start to run more often if some other application needs the memory. ... manual garbage collection but I haven't had to use it in a long time ... since we have decent machines here and I have learned to slim down my ...
    (microsoft.public.dotnet.languages.csharp)