Muokkaa

Jaa


<gcServer> element

Specifies whether the common language runtime runs server garbage collection.

<configuration>
  <runtime>
    <gcServer>

Syntax

<gcServer
   enabled="true|false"/>

Attributes and elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Description
enabled Required attribute.

Specifies whether the runtime runs server garbage collection.

enabled attribute

Value Description
false Does not run server garbage collection. This is the default.
true Runs server garbage collection.

Child elements

None.

Parent elements

Element Description
configuration The root element in every configuration file used by the common language runtime and .NET Framework applications.
runtime Contains information about assembly binding and garbage collection.

Remarks

The common language runtime (CLR) supports two types of garbage collection: workstation garbage collection, which is available on all systems, and server garbage collection, which is available on multiprocessor systems. Use the gcServer element to control the type of garbage collection the CLR performs. Use the GCSettings.IsServerGC property to determine if server garbage collection is enabled.

For single-processor computers, the default workstation garbage collection should be the fastest option. Either workstation or server can be used for two-processor computers. Server garbage collection should be the fastest option for more than two processors. Most commonly, multiprocessor server systems disable server GC and use workstation GC instead when many instances of a server app run on the same machine.

This element can be used only in the application configuration file; it is ignored if it is in the machine configuration file.

Note

In the .NET Framework 4 and earlier versions, concurrent garbage collection is not available when server garbage collection is enabled. Starting with .NET Framework 4.5, server garbage collection is concurrent. To use non-concurrent server garbage collection, set the gcServer element to true and the gcConcurrent element to false.

Starting with .NET Framework 4.6.2, you can also use the following elements to configure server GC:

  • GCNoAffinitize, which specifies whether there is an affinity between server GC heaps and processors. By default, there is one server GC heap for each processor.

  • GCHeapCount, which limits the number of heaps used by a process.

  • GCHeapAffinitizeMask, which defines the affinity between the available server GC heaps and individual processors.

Example

The following example enables server garbage collection:

<configuration>
   <runtime>
      <gcServer enabled="true"/>
   </runtime>
</configuration>

See also