This blog has moved!

Check out www.CodeBetter.com/blogs/grant.killian

<September 2008>
SuMoTuWeThFrSa
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011


Navigation

Professional Props...

Extracurricular Props...

Subscriptions

Article Categories



More thoughts on Garbage Collection

Ever beat a dead horse?

Brent Rector of Wintellect discusses Finalizers, sharing how the GC process really behaves and why we should think twice thrice before using Finalizers.  Make sure your design warrants the extra overhead.

Other highlights from Brent's article include:

  • Despite some semantic parallels, C++ destructors behave very differently than C# destructors (and .Net destructors in general).
  • Using Finalizers can cause a significant performance penalty, especially when one considers the multi-step process (and threads) involved with Finalization.
  • If you must use a Finalizer, keep it as simple as possible.
  • His opinion is that since Java has finalizers, MSFT added finalizers to .Net to match up in a feature-by-feature comparison with Java
  • You can use the Dispose pattern if you want to achieve non-deterministic finalization (I discussed this here)

If you must use Finalizers in your design, keep them brief and free of exception-throwing code; use the Dispose()    pattern and document your classes so clients know to invoke the Dispose() method appropriately (or with a using statement in c#). 

posted on Thursday, August 21, 2003 11:01 AM by grant.killian





Powered by Dot Net Junkies, by Telligent Systems