Re: Finalizer vs. Dispose
From: Brock Allen (ballen_at_develop.com.i_hate_spam_too)
Date: 03/18/05
- Next message: Chris Lyon [MSFT]: "Re: Finalizer vs. Dispose"
- Previous message: Chee Pin Cheam: "Re: Finalizer vs. Dispose"
- In reply to: Jochen Kalmbach: "Re: Finalizer vs. Dispose"
- Next in thread: Chris Lyon [MSFT]: "Re: Finalizer vs. Dispose"
- Reply: Chris Lyon [MSFT]: "Re: Finalizer vs. Dispose"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 17 Mar 2005 16:39:54 -0800
> Mostly all .NET classes which implements IDisposable, also implements
> an finalizer.
I disagree. The Finalizer is really there for non-managed resources that
the GC has no idea how to properly cleanp. Think Win32 handles that your
code went out thru interop to acquire. If you don't have those sorts of resources,
then don't implement a Finalizer as it slows your app down and the memory
for your objects hang around longer than they need to. I'd say the converse
is more accurate: "All classes that have a Finalizer should also implement
IDisposable".
IDisposable, as already mentioned, is just a pattern that alerts the client
of your code that Dispose needs to be called as soon as you're done with
this object. This allows more aggresive cleanup of resources (both managed
and unmanaged). If all you hold are managed resources, then IDisposable is
sufficient, yet important.
-Brock
DevelopMentor
http://staff.develop.com/ballen
- Next message: Chris Lyon [MSFT]: "Re: Finalizer vs. Dispose"
- Previous message: Chee Pin Cheam: "Re: Finalizer vs. Dispose"
- In reply to: Jochen Kalmbach: "Re: Finalizer vs. Dispose"
- Next in thread: Chris Lyon [MSFT]: "Re: Finalizer vs. Dispose"
- Reply: Chris Lyon [MSFT]: "Re: Finalizer vs. Dispose"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|