Re: GC and dispose
- From: "Simon Hart" <srhartone@xxxxxxxxx>
- Date: Wed, 21 Jun 2006 16:34:01 +0100
Agree. We often use the Dispose (IDisposable) for cleaning managed resources
as well as unmanaged. We tend to use the Finalizer (Destructor) for
unmanaged deallocation.
Regards
Simon.
"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
wrote in message news:uuTrPmTlGHA.4536@xxxxxxxxxxxxxxxxxxxxxxx
Daniel Billingsley wrote:
As somebody else said, the Dispose pattern is for making sure
UNMANAGED resources inside your classes get cleaned up.
I would take exception with that statement. Dispose is for making sure
resources that are not simply managed heap allocations get cleaned up.
Unmanaged resources such as handles or Win32 memory allocations are fine
examples of such, but there are certainly managed examples as well. A
common example of a managed resource that needs to be explicitly cleaned
up is a callback (delegate) which can keep an object alive long after
you're done with it, consuming both memory and CPU resources making
callbacks to an object that no one cares about anymore.
-cd
.
- Follow-Ups:
- Re: GC and dispose
- From: Markus Stoeger
- Re: GC and dispose
- References:
- GC and dispose
- From: Petros Amiridis
- Re: GC and dispose
- From: Phil Wilson
- Re: GC and dispose
- From: Petros Amiridis
- Re: GC and dispose
- From: Daniel Billingsley
- Re: GC and dispose
- From: Carl Daniel [VC++ MVP]
- GC and dispose
- Prev by Date: Re: String.IndexOf(string, int, int) bug? help!
- Next by Date: Re: Font representation
- Previous by thread: Re: GC and dispose
- Next by thread: Re: GC and dispose
- Index(es):
Relevant Pages
|