This blog has moved!

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

<July 2008>
SuMoTuWeThFrSa
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789


Navigation

Professional Props...

Extracurricular Props...

Subscriptions

Article Categories



Thursday, August 21, 2003 - Posts

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 Thursday, August 21, 2003 11:01 AM by grant.killian




Powered by Dot Net Junkies, by Telligent Systems