Re: GC and dispose
- From: Göran Andersson <guffa@xxxxxxxxx>
- Date: Thu, 22 Jun 2006 00:23:20 +0200
Markus Stoeger wrote:
Simon Hart wrote: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.
Could you explain why you prefer the finalizer instead of a manual call to Dispose for freeing unmanaged resources?
As far as I know you can never tell when the GC will finalize an object. So it might keep floating around forever as well. Which means that you could run out of handles for example.
Maybe I've misunderstood something behind GC and the finalizer?.
Max
No, that is correct.
The Dispose method should be used to free resources. The finalizer should call Dispose as a backup if the program failed to call it.
.
- Follow-Ups:
- Re: GC and dispose
- From: Carl Daniel [VC++ MVP]
- 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]
- Re: GC and dispose
- From: Simon Hart
- Re: GC and dispose
- From: Markus Stoeger
- GC and dispose
- Prev by Date: Re: GC and dispose
- Next by Date: Re: When is Debug.Assert pertinent to use ?
- Previous by thread: Re: GC and dispose
- Next by thread: Re: GC and dispose
- Index(es):
Relevant Pages
|