Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The standard CLR uses a generational mark-and-compact GC that performs automatic memory management for objects stored on the managed heap. The GC is considered to be a tracing garbage collector in that it doesn’t interfere with every access to an object, but rather wakes up intermittently and traces the graph of objects stored on the managed heap to determine which objects can be considered garbage and therefore collected.
The GC initiates a garbage collection upon performing a memory
allocation (via the new keyword) either
after a certain threshold of memory has been allocated, or at other times
to reduce the application’s memory footprint. This process can also be
initiated manually by calling System.GC.Collect. During
a garbage collection, all threads may by frozen (more on this in the next
section).