GCCollectionMode Enumeration


Specifies the behavior for a forced garbage collection.

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

Public Enumeration GCCollectionMode

Member nameDescription

The default setting for this enumeration, which is currently Forced.


Forces the garbage collection to occur immediately.


Allows 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.

Imports System

Class Program

    Public Shared Sub Main()
        GC.Collect(2, GCCollectionMode.Optimized)
    End Sub
End Class

Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top