The GC Class

The GC class publishes services to interface with the garbage collector. You can manipulate and monitor garbage collection with the GC class. While some of the commands provide status information, other GC commands affect the default behavior of garbage collection. Table 17-2 lists the static members of the GC class.

Table 17-2. GC class static members

Member name

Description

MaxGeneration

This property is an integer property and returns the maximum number of generations.

AddMemoryPressure

This method recognizes memory allocations for unmanaged resources.

Collect

This method forces garbage collection on a specific generation. There are two overloads of the method. The no-argument Collect does garbage collection on all generations. The one-argument ...

Get Programming Microsoft® Visual C#® 2008: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.