New GCCollectionMode in ORCAS
Posted on 4/19/2007 10:20:38 PM
in #C Sharp
Hi
With orcas there is a new addition to the GC class. There is a new overload being added to the GC class Collect method. The new overload takes two parameters, int Generation and GCCollectionMode.
Here generation is the heighest generation to collect. The value can be anything between 0 and GC.MaxGeneration. Mode can be either default, Forced or Optimized. Default has the same effect as calling the GC.Collect without providing any mode. Forced mode guarantee's a collection for all generation upto and including generation provided in earlier parameter
Optimized mode tells GC to collect only if GC determines it to be productive to collect the Garbage. The productivity of Garbage collection is determined on many factors which includes amount of memory considered garbage, heap fragmentation etc. If GC decides that a garbage collection will not be productive currently then this call has no affect what so ever.
Forced and default modes should be used mainly for debugging or testing purpose, when we want to ensure objects are being collected at a certain point in the application or to compare the performance of the application based on Garbage Application.
Thanks Vikram
|