> On 9/6/07, Russell Collins <[EMAIL PROTECTED]> wrote:
> >
> > 1.  Every object has a finalizer as well as a constructor in .NET
> > whether you declare it or not.
>
>
> I believe you're mistaken.  Do you have a link to some documentation of
> this?
>
> --
> Steve Johnson

I'm with you, Steve.  Only types defined below System.Object that have
overridden Finalize methods are called post-GC by the finalizer thread.  The
finalizer thread doesn't waste any cycles calling the no-op
System.Object.Finalize for instances of nonfinalizable types.

Although I can't cite any docs, it's easy enough to prove this in vs.net or
windbg using !sos.finalizequeue.  Each allocation of finalizable types
(types anywhere below System.Object that override System.Object.Finalize)
causes a corresponding entry to be placed on the list !sos.finalizequeue
displays.  Allocation of non-finalizable types has no effect on that list.
It's this list that's consulted down the road by subsequent GC's in order to
determine which otherwise-garbage objects need to have their finalizer
called (modulo their use of GC.SuppressFinalize in the interim).

-Mike
Bear Canyon Consulting LLC
http://www.bearcanyon.com
http://www.pluralsight.com/mike

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to