Not only does it make the GC inefficient, but it also chews up processor time in
the finalization thread.
nNote When an object has a finalizer, it is placed on an internal CLR queue to keep track of this fact, and,
clearly, GC.SuppressFinalize() affects that status. During normal execution, you cannot guarantee that
other object references are reachable. However, during application shutdown, the finalizer thread actually
finalizes the objects right off of this internal finalizable queue, and therefore, those objects are reachable
and can be referenced in finalizers. You can determine if this is the case by using Environment.
HasShutdownStarted or AppDomain.IsFinalizingForUnload. However, give careful consideration
before doing so, and don??™t be surprised if this behavior changes in future versions of the CLR.
Let??™s examine the finalizer performance impact on the GC a little closer. The CLR GC is
implemented as a generational GC. This means that allocated objects that live in higher generations
are assumed to live longer than those that live in lower generations and are collected
less frequently than the generation below them. The fine details of the GC??™s collection algorithm
are beyond the scope of this book, but it??™s beneficial to touch upon them at a high level.
Pages:
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554