Expand Minimize

GCCollectionMode Enumeration

July 28, 2014

Specifies the behavior for a forced garbage collection.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public enum GCCollectionMode

Member nameDescription
DefaultThe default setting for this enumeration, which is currently Forced.
ForcedForces the garbage collection to occur immediately.
OptimizedAllows the garbage collector to determine whether the current time is optimal to reclaim objects.

Use the GC.Collect method overload to specify the GCCollectionMode value.

The following example forces a garbage collection for generation 2 objects with the Optimized setting.

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2014 Microsoft