Editare

Partajați prin


GCSettings.IsServerGC Property

Definition

Gets a value that indicates whether server garbage collection is enabled.

public:
 static property bool IsServerGC { bool get(); };
public static bool IsServerGC { get; }
static member IsServerGC : bool
Public Shared ReadOnly Property IsServerGC As Boolean

Property Value

true if server garbage collection is enabled; otherwise, false.

Examples

The following example indicates whether the host computer is using server or workstation garbage collection.

using System;
using System.Runtime;

class Sample
{
    public static void Main()
    {
        string result;

        if (GCSettings.IsServerGC)
            result = "server";
        else
            result = "workstation";
        Console.WriteLine("The {0} garbage collector is running.", result);
    }
}
// The example displays output like the following:
//      The workstation garbage collector is running.
Imports System.Runtime

Class Sample
   Public Shared Sub Main()
      Dim result As String
      
      If GCSettings.IsServerGC = True Then
         result = "server"
      Else
         result = "workstation"
      End If
      Console.WriteLine("The {0} garbage collector is running.", result)
   End Sub
End Class 
' The example displays output like the following:
'      The workstation garbage collector is running.

Remarks

For information about server garbage collection, see Workstation and Server Garbage Collection.

If server garbage collection is not enabled, workstation garbage collection is in effect (with or without concurrent collection). Server garbage collection is available only on multiprocessor computers.

An unmanaged host can request server garbage collection, and the host request overrides configuration file settings. If the host does not specify the type of garbage collection, you can use a configuration setting to specify server garbage collection. For more information, see Configure workstation vs. server.

Applies to