GCCollectionMode GCCollectionMode GCCollectionMode GCCollectionMode Enum

定义

指定强制垃圾回收的行为。Specifies the behavior for a forced garbage collection.

public enum class GCCollectionMode
[System.Serializable]
public enum GCCollectionMode
type GCCollectionMode = 
Public Enum GCCollectionMode
继承
GCCollectionModeGCCollectionModeGCCollectionModeGCCollectionMode
属性

字段

Default Default Default Default 0

此枚举的默认设置,它当前为 ForcedThe default setting for this enumeration, which is currently Forced.

Forced Forced Forced Forced 1

强制立即执行垃圾回收。Forces the garbage collection to occur immediately.

Optimized Optimized Optimized Optimized 2

使垃圾回收器可以确定当前时间是否是回收对象的最佳时间。Allows the garbage collector to determine whether the current time is optimal to reclaim objects.

示例

下面的示例强制使用优化设置为第 2 代对象进行垃圾回收。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);
    }
}
Imports System

Class Program

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

注解

使用GC.Collect方法重载来指定GCCollectionMode值。Use the GC.Collect method overload to specify the GCCollectionMode value.

适用于

另请参阅