<gcConcurrent> Element

Specifies whether the common language runtime runs garbage collection on a separate thread.

<configuration> Element
  <runtime> Element
    <gcConcurrent> Element
<gcConcurrent  
   enabled="true|false"/>

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

Attributes

Attribute

Description

enabled

Required attribute.

Specifies whether the runtime runs garbage collection concurrently.

enabled Attribute

Value

Description

false

Does not run garbage collection concurrently.

true

Runs garbage collection concurrently. This is the default.

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.

Prior to the .NET Framework 4, workstation garbage collection supported concurrent garbage collection, which performed garbage collection in the background on a separate thread. In the .NET Framework 4, concurrent garbage collection was replaced by background GC, which also performs garbage collection in the background on a separate thread. Starting with the .NET Framework 4.5, background collection became available in server garbage collection. The <gcConcurrent> element controls whether the runtime performs either concurrent or background garbage collection, if it is available, or whether it performs garbage collection in the foreground.

Caution noteCaution

Starting with the .NET Framework 4, concurrent garbage collection is replaced by background garbage collection. The terms concurrent and background are used interchangeably in the .NET Framework documentation. To disable background garbage collection, use the <gcConcurrent> element, as discussed in this article.

By default, the runtime uses concurrent or background garbage collection, which is optimized for latency. If your application involves heavy user interaction, leave concurrent garbage collection enabled to minimize the application's pause time to perform garbage collection. If you set the enabled attribute of the <gcConcurrent> element to false, the runtime uses non-concurrent garbage collection, which is optimized for throughput. The following configuration file disables background garbage collection.

<configuration>
   <runtime>
      <gcConcurrent enabled="false"/>
   </runtime>
</configuration>

If there is a <gcConcurrentSetting> setting in the machine configuration file, it defines the default value for all .NET Framework applications. The machine configuration file setting overrides the application configuration file setting.

For more information on concurrent and background garbage collection, see the "Concurrent garbage collection" section in the Fundamentals of Garbage Collection topic.

The following example enables concurrent garbage collection.

<configuration>
   <runtime>
      <gcConcurrent enabled="true"/>
   </runtime>
</configuration>
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft