Export (0) Print
Expand All
Expand Minimize

GCCollectionMode Enumeration

Specifies the behavior for a forced garbage collection.

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

[SerializableAttribute]
public enum GCCollectionMode

Member nameDescription
Supported by Portable Class LibraryDefaultThe default setting for this enumeration, which is currently Forced.
Supported by Portable Class LibraryForcedForces the garbage collection to occur immediately.
Supported by Portable Class LibraryOptimizedAllows 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.

using System;

class Program
{
    static void Main(string[] args)
    {
        GC.Collect(2, GCCollectionMode.Optimized);
    }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5 SP1, 3.0 SP1, 2.0 SP1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft