Skip to content

Update .NET Framework GC config info #12959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
Nov 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b515f68
Documented additional GC switches, config switches
Jun 20, 2019
943dfe0
Additional changes
Jun 21, 2019
3ab7b25
Documented additional GC switches, config switches
Jun 20, 2019
9c245c8
Additional changes
Jun 21, 2019
d963d2e
Updated TOC
Jun 21, 2019
0c8df3e
Resolved merge conflict
Jun 21, 2019
30f0244
Removed some environment variables
Jun 24, 2019
7c0bc28
Fixed TOC, corrected bad links, xrefs
Jun 24, 2019
dcbb309
Merge branch 'master' into gc-config
Aug 20, 2019
c4c3cd9
Update envvars.md
Aug 20, 2019
cfde389
Merge branch 'master' into gc-config
Aug 28, 2019
1fb0a56
Merge branch 'master' into gc-config
Oct 4, 2019
000ca3a
Merge branch 'master' into gc-config
mairaw Oct 11, 2019
4db4903
Update envvars.md
mairaw Oct 11, 2019
1d6cb16
Update runtimeconfig.md
mairaw Oct 11, 2019
c1e0e8b
Update gcheapaffinitizemask-element.md
mairaw Oct 11, 2019
e7ea5f7
Update gcheapcount-element.md
mairaw Oct 11, 2019
13b4ed9
Update gcnoaffinitize-element.md
mairaw Oct 11, 2019
6d28004
Update gcheapcount-element.md
mairaw Oct 11, 2019
9b390d4
Update gcheapaffinitizemask-element.md
mairaw Oct 11, 2019
b687757
readd TOC
mairaw Oct 11, 2019
151f17b
Update envvars.md
mairaw Oct 11, 2019
18addeb
Update index.md
mairaw Oct 11, 2019
064bca1
Update runtimeconfig.md
mairaw Oct 11, 2019
2e203c2
Update gcheapaffinitizemask-element.md
mairaw Oct 11, 2019
08f5ede
Update gcheapcount-element.md
mairaw Oct 11, 2019
671bb13
Update gcnoaffinitize-element.md
mairaw Oct 11, 2019
c1b4a34
clean trailing spaces
mairaw Oct 11, 2019
e444c8d
Update docs/core/runtime-config/envvars.md
Oct 11, 2019
2edb62d
Update docs/core/runtime-config/index.md
Oct 11, 2019
6b7300d
Update index.md
Oct 11, 2019
9f67e81
Update index.md
Oct 11, 2019
f3724d6
resolve merge conflict - separate toc
gewarren Oct 22, 2019
71a5927
fix toc paths
gewarren Oct 22, 2019
7c4d5e1
remove empty line
mairaw Oct 22, 2019
f030208
remove extra space
mairaw Oct 22, 2019
569d9cf
remove changes that are taken care of by prs #15760 and #15761
gewarren Nov 8, 2019
7c0712e
Merge branch 'gc-config' of github.com:rpetrusha/docs into ron
gewarren Nov 8, 2019
4411e0c
feedback from jan
gewarren Nov 8, 2019
42da1fa
fix copy/paste error in link
gewarren Nov 9, 2019
d9abdea
remove core config files from this pr
gewarren Nov 9, 2019
2119ad3
add new elements to index file and parent element table; toc improvem…
gewarren Nov 9, 2019
ab0eff4
review on staging - mostly xml formatting
gewarren Nov 9, 2019
4bb13f4
review on staging
gewarren Nov 9, 2019
9ff9588
further review on staging
gewarren Nov 9, 2019
a523641
fix see alsos and quotation marks
gewarren Nov 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
---
title: "<gcConcurrent> Element"
title: gcConcurrent Element
ms.date: "03/30/2017"
f1_keywords:
f1_keywords:
- "http://schemas.microsoft.com/.NetConfiguration/v2.0#configuration/runtime/gcConcurrent"
- "http://schemas.microsoft.com/.NetConfiguration/v2.0#gcConcurrent"
helpviewer_keywords:
helpviewer_keywords:
- "container tags, <gcConcurrent> element"
- "gcConcurrent element"
- "<gcConcurrent> element"
ms.assetid: 503f55ba-26ed-45ac-a2ea-caf994da04cd
author: "rpetrusha"
ms.author: "ronpet"
---
# \<gcConcurrent> Element
# \<gcConcurrent> element

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

[**\<configuration>**](../configuration-element.md)\
&nbsp;&nbsp;[**\<runtime>**](runtime-element.md)\
&nbsp;&nbsp;&nbsp;&nbsp;**\<gcConcurrent>**
[\<configuration>](../configuration-element.md)\
&nbsp;&nbsp;[\<runtime>](runtime-element.md)\
&nbsp;&nbsp;&nbsp;&nbsp;\<gcConcurrent>

## Syntax

Expand All @@ -35,9 +35,9 @@ The following sections describe attributes, child elements, and parent elements.

|Attribute|Description|
|---------------|-----------------|
|`enabled`|Required attribute.<br /><br /> Specifies whether the runtime runs garbage collection concurrently.|
|`enabled`|Required attribute.<br /><br />Specifies whether the runtime runs garbage collection concurrently.|

## enabled attribute
#### enabled attribute

|Value|Description|
|-----------|-----------------|
Expand All @@ -57,14 +57,16 @@ None.

## Remarks

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's available, or whether it performs garbage collection in the foreground.
Prior to .NET Framework 4, workstation garbage collection supported concurrent garbage collection, which performed garbage collection in the background on a separate thread. In .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 .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's available, or whether it performs garbage collection in the foreground.

### To disable background garbage collection

> [!WARNING]
> 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.
> Starting with .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.
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:

```xml
<configuration>
Expand All @@ -74,13 +76,13 @@ By default, the runtime uses concurrent or background garbage collection, which
</configuration>
```

If there's 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.
If there's 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](../../../../standard/garbage-collection/fundamentals.md#concurrent-garbage-collection) section in the [Fundamentals of Garbage Collection](../../../../standard/garbage-collection/fundamentals.md) article.
For more information on concurrent and background garbage collection, see the [Concurrent garbage collection](../../../../standard/garbage-collection/fundamentals.md#concurrent-garbage-collection), [Background workstation garbage collection](../../../../standard/garbage-collection/fundamentals.md#background-workstation-garbage-collection), and [Background server garbage collection](../../../../standard/garbage-collection/fundamentals.md#background-server-garbage-collection) sections in the [Fundamentals of Garbage Collection](../../../../standard/garbage-collection/fundamentals.md) article.

## Example

The following example enables concurrent garbage collection:
The following example enables background garbage collection:

```xml
<configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
title: GCHeapAffinitizeMask element
ms.date: 11/08/2019
helpviewer_keywords:
- "gcHeapCount element"
- "<gcHeapCount> element"
---
# \<GCHeapAffinitizeMask> element

Defines the affinity between GC heaps and individual processors.

\<configuration>\
&nbsp;&nbsp;\<runtime>\
&nbsp;&nbsp;&nbsp;&nbsp;\<GCHeapAffinitizeMask>

## Syntax

```xml
<GCHeapAffinitizeMask
enabled="nnnn"/>
```

## Attributes and elements

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

### Attributes

|Attribute|Description|
|---------------|-----------------|
|`enabled`|Required attribute.<br /><br />Specifies the affinity between GC heaps and individual processors. |

#### enabled attribute

|Value|Description|
|-----------|-----------------|
|`nnnn`|A decimal value that forms a bitmask defining the affinity between server GC heaps and individual processors. |

### 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

By default, server GC threads are hard-affinitized with their respective CPU so that there is one GC heap, one server GC thread, and one background server GC thread for each processor. Starting with .NET Framework 4.6.2, you can use the **GCHeapAffinitizeMask** element to control the affinity between server GC heaps and processors when the number of heaps is limited by the **GCHeapCount** element.

**GCHeapAffinitizeMask** is typically used along with two other flags:

- [GCNoAffinitize](gcnoaffinitize-element.md), which controls whether server GC threads/heaps are affinitized with CPUs. The `enabled` attribute of the [GCNoAffinitize](gcnoaffinitize-element.md) element must be `false` (its default value) for the **GCHeapAffinitizeMask** setting to be used.

- [GCHeapCount](gcheapcount-element.md), which limits the number of heaps used by the process for server GC. By default, there is one heap for each processor.

**nnnn** is a bit mask expressed as a decimal value. Bit 0 of byte 0 represents processor 0, bit 1 of byte 0 represents processor 1, and so on. For example:

```xml
<GCHeapAffinitizeMask enabled="1023"/>
```

A value of 1023 is 0x3FF or 0011 1111 1111b. The process uses 10 processors, from processor 0 through processor 9.

## Example

The following example indicates that an application uses server GC with 10 heaps/threads. Since you don't want those heaps to overlap with heaps from other applications running on the system, use **GCHeapAffinitizeMask** to specify that the process should use CPUs 0 through 9.

```xml
<configuration>
<runtime>
<gcServer enabled="true"/>
<GCHeapCount enabled="10"/>
<GCHeapAffinitizeMask enabled="1023"/>
</runtime>
</configuration>
```

## See also

- <xref:System.Runtime.GCSettings.IsServerGC%2A?displayProperty=nameWithType>
- [GCNoAffinitize element](gcnoaffinitize-element.md)
- [GCHeapCount element](gcheapcount-element.md)
- [Fundamentals of garbage collection](../../../../standard/garbage-collection/fundamentals.md)
- [Runtime Settings Schema](index.md)
- [Configuration File Schema](../index.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
title: GCHeapCount element
ms.date: 11/08/2019
helpviewer_keywords:
- "gcHeapCount element"
- "<gcHeapCount> element"
---
# \<GCHeapCount> element

Specifies the number of heaps/threads to use for server garbage collection.

\<configuration>\
&nbsp;&nbsp;\<runtime>\
&nbsp;&nbsp;&nbsp;&nbsp;\<GCHeapCount>

## Syntax

```xml
<GCHeapCount
enabled="nn"/>
```

## Attributes and elements

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

### Attributes

|Attribute|Description|
|---------------|-----------------|
|`enabled`|Required attribute.<br /><br />Specifies the number of heaps to use for server garbage collection. The actual number of heaps is the minimum of the number of heaps you specify and the number of processors your process is allowed to use. |

#### enabled attribute

|Value|Description|
|-----------|-----------------|
|`nn`|The number of heaps to use for server GC.|

### 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

By default, server GC threads are hard-affinitized with their respective CPU so that there is one GC heap, one server GC thread, and one background server GC thread for each processor. Starting with .NET Framework 4.6.2, you can use the **GCHeapCount** element to limit the number of heaps used by your application for server GC. Limiting the number of heaps used for server GC is particularly useful for systems that run multiple instances of a server application.

**GCHeapCount** is typically used along with two other flags:

- [GCNoAffinitize](gcnoaffinitize-element.md), which controls whether server GC threads/heaps are affinitized with CPUs.

- [GCHeapAffinitizeMask](gcheapaffinitizemask-element.md), which controls the affinity of GC threads/heaps with CPUs.

If **GCHeapCount** is set and **GCNoAffinitize** is disabled (its default setting), there is an affinity between the *nn* GC threads/heaps and the first *nn* processors. You can use the **GCHeapAffinitizeMask** element to specify which processors are used by the process' server GC heaps. Otherwise, if multiple server processes are running on a system, their processor usage will overlap.

If **GCHeapCount** is set and **GCNoAffinitize** is enabled, the garbage collector limits the number of processors used for server GC but does not affinitize GC heaps and processors.

## Example

The following example indicates that an application uses server GC with 10 heaps/threads. Since you don't want those heaps to overlap with heaps from other applications running on the system, you use the **GCHeapAffinitizeMask** to specify that the process should use CPUs 0 through 9.

```xml
<configuration>
<runtime>
<gcServer enabled="true"/>
<GCHeapCount enabled="10"/>
<GCHeapAffinitizeMask enabled="1023"/>
</runtime>
</configuration>
```

The following example does not affinitize server GC threads and limits the number of GC heaps/threads to 10.

```xml
<configuration>
<runtime>
<gcServer enabled="true"/>
<GCHeapCount enabled="10"/>
<GCNoAffinitize enabled="true"/>
</runtime>
</configuration>
```

## See also

- <xref:System.Runtime.GCSettings.IsServerGC%2A?displayProperty=nameWithType>
- [GCNoAffinitize element](gcnoaffinitize-element.md)
- [GCHeapAffinitizeMask element](gcheapaffinitizemask-element.md)
- [Fundamentals of garbage collection](../../../../standard/garbage-collection/fundamentals.md)
- [Runtime Settings Schema](index.md)
- [Configuration File Schema](../index.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
title: GCNoAffinitize element
ms.date: 11/08/2019
helpviewer_keywords:
- "gcNoAffinitize element"
- "<gcNoAffinitize> element"
---
# \<GCNoAffinitize> element

Specifies whether or not to affinitize server GC threads with CPUs.

\<configuration>\
&nbsp;&nbsp;\<runtime>\
&nbsp;&nbsp;&nbsp;&nbsp;\<GCNoAffinitize>

## Syntax

```xml
<GCNoAffinitize
enabled="true|false"/>
```

## Attributes and elements

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

### Attributes

|Attribute|Description|
|---------------|-----------------|
|`enabled`|Required attribute.<br /><br />Specifies whether server GC threads/heaps are affinitized with the processors available on the machine.|

#### enabled attribute

|Value|Description|
|-----------|-----------------|
|`false`|Affinitizes server GC threads with CPUs. This is the default.|
|`true`|Does not affinitize server GC threads with CPUs.|

### 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

By default, server GC threads are hard-affinitized with their respective CPUs. Each of the system's available processors has its own GC heap and thread. This is typically the preferred setting since it optimizes cache usage. Starting with .NET Framework 4.6.2, by setting the **GCNoAffinitize** element's `enabled` attribute to `false`, you can specify that server GC threads and CPUs should not be tightly coupled.

You can specify the **GCNoAffinitize** configuration element alone to not affinitize server GC threads with CPUs. You can also use it along with the [GCHeapCount](gcheapcount-element.md) element to control the number of GC heaps and threads used by an application.

If the `enabled` attribute of the **GCNoAffinitize** element is `false` (its default value), you can also use the [GCHeapCount](gcheapcount-element.md) element to specify the number of GC threads and heaps, along with the [GCHeapAffinitizeMask](gcheapaffinitizemask-element.md) element to specify the processors to which the GC threads and heaps are affinitized.

## Example

The following example does not hard-affinitize server GC threads:

```xml
<configuration>
<runtime>
<gcServer enabled="true"/>
<GCNoAffinitize enabled="true"/>
</runtime>
</configuration>
```

The following example does not affinitize server GC threads and limits the number of GC heaps/threads to 10:

```xml
<configuration>
<runtime>
<gcServer enabled="true"/>
<GCHeapCount enabled="10"/>
<GCNoAffinitize enabled="true"/>
</runtime>
</configuration>
```

## See also

- <xref:System.Runtime.GCSettings.IsServerGC%2A?displayProperty=nameWithType>
- [GCHeapAffinitizeMask element](gcheapaffinitizemask-element.md)
- [GCHeapCount element](gcheapcount-element.md)
- [Fundamentals of garbage collection](../../../../standard/garbage-collection/fundamentals.md)
- [Runtime Settings Schema](index.md)
- [Configuration File Schema](../index.md)
Loading