Skip to content

Commit e34a21e

Browse files
Add GC heap limit settings (#19423)
* fixes #19356 Co-authored-by: David Pine <david.pine@microsoft.com>
1 parent b7dec7a commit e34a21e

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

docs/core/run-time-config/garbage-collector.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Garbage collector config settings
33
description: Learn about run-time settings for configuring how the garbage collector manages memory for .NET Core apps.
4-
ms.date: 01/09/2020
4+
ms.date: 07/10/2020
55
ms.topic: reference
66
---
77
# Run-time configuration options for garbage collection
@@ -234,6 +234,7 @@ Example:
234234

235235
- Specifies the maximum commit size, in bytes, for the GC heap and GC bookkeeping.
236236
- This setting only applies to 64-bit computers.
237+
- This setting is ignored if the [Per-object-heap limits](#per-object-heap-limits) are configured.
237238
- The default value, which only applies in certain cases, is the greater of 20 MB or 75% of the memory limit on the container. The default value applies if:
238239

239240
- The process is running inside a container that has a specified memory limit.
@@ -265,6 +266,7 @@ Example:
265266
- If [System.GC.HeapHardLimit](#systemgcheaphardlimitcomplus_gcheaphardlimit) is also set, this setting is ignored.
266267
- This setting only applies to 64-bit computers.
267268
- If the process is running inside a container that has a specified memory limit, the percentage is calculated as a percentage of that memory limit.
269+
- This setting is ignored if the [Per-object-heap limits](#per-object-heap-limits) are configured.
268270
- The default value, which only applies in certain cases, is the lesser of 20 MB or 75% of the memory limit on the container. The default value applies if:
269271

270272
- The process is running inside a container that has a specified memory limit.
@@ -290,6 +292,40 @@ Example:
290292
> [!TIP]
291293
> If you're setting the option in *runtimeconfig.json*, specify a decimal value. If you're setting the option as an environment variable, specify a hexadecimal value. For example, to limit the heap usage to 30%, the values would be 30 for the JSON file and 0x1E or 1E for the environment variable.
292294
295+
### Per-object-heap limits
296+
297+
You can specify the GC's allowable heap usage on a per-object-heap basis. The different heaps are the large object heap (LOH), small object heap (SOH), and pinned object heap (POH).
298+
299+
#### COMPLUS_GCHeapHardLimitSOH, COMPLUS_GCHeapHardLimitLOH, COMPLUS_GCHeapHardLimitPOH
300+
301+
- If you specify a value for any of the `COMPLUS_GCHeapHardLimitSOH`, `COMPLUS_GCHeapHardLimitLOH`, or `COMPLUS_GCHeapHardLimitPOH` settings, you must also specify a value for `COMPLUS_GCHeapHardLimitSOH` and `COMPLUS_GCHeapHardLimitLOH`. If you don't, the runtime will fail to initialize.
302+
- The default value for `COMPLUS_GCHeapHardLimitPOH` is 0. `COMPLUS_GCHeapHardLimitSOH` and `COMPLUS_GCHeapHardLimitLOH` don't have default values.
303+
304+
| | Setting name | Values | Version introduced |
305+
| - | - | - | - |
306+
| **Environment variable** | `COMPLUS_GCHeapHardLimitSOH` | *hexadecimal value* | .NET 5.0 |
307+
| **Environment variable** | `COMPLUS_GCHeapHardLimitLOH` | *hexadecimal value* | .NET 5.0 |
308+
| **Environment variable** | `COMPLUS_GCHeapHardLimitPOH` | *hexadecimal value* | .NET 5.0 |
309+
310+
> [!TIP]
311+
> If you're setting the option as an environment variable, specify a hexadecimal value. For example, to specify a heap hard limit of 200 mebibytes (MiB), the value would be 0xC800000 or C800000.
312+
313+
#### COMPLUS_GCHeapHardLimitSOHPercent, COMPLUS_GCHeapHardLimitLOHPercent, COMPLUS_GCHeapHardLimitPOHPercent
314+
315+
- If you specify a value for any of the `COMPLUS_GCHeapHardLimitSOHPercent`, `COMPLUS_GCHeapHardLimitLOHPercent`, or `COMPLUS_GCHeapHardLimitPOHPercent` settings, you must also specify a value for `COMPLUS_GCHeapHardLimitSOHPercent` and `COMPLUS_GCHeapHardLimitLOHPercent`. If you don't, the runtime will fail to initialize.
316+
- These settings are ignored if `COMPLUS_GCHeapHardLimitSOH`, `COMPLUS_GCHeapHardLimitLOH`, and `COMPLUS_GCHeapHardLimitPOH` are specified.
317+
- A value of 1 means that GC uses 1% of total physical memory for that object heap.
318+
- Each value must be greater than zero and less than 100. Additionally, the sum of the three percentage values must be less than 100. Otherwise, the runtime will fail to initialize.
319+
320+
| | Setting name | Values | Version introduced |
321+
| - | - | - | - |
322+
| **Environment variable** | `COMPLUS_GCHeapHardLimitSOHPercent` | *hexadecimal value* | .NET 5.0 |
323+
| **Environment variable** | `COMPLUS_GCHeapHardLimitLOHPercent` | *hexadecimal value* | .NET 5.0 |
324+
| **Environment variable** | `COMPLUS_GCHeapHardLimitPOHPercent` | *hexadecimal value* | .NET 5.0 |
325+
326+
> [!TIP]
327+
> If you're setting the option as an environment variable, specify a hexadecimal value. For example, to limit the heap usage to 30%, the value would be 0x1E or 1E.
328+
293329
### System.GC.RetainVM/COMPlus_GCRetainVM
294330

295331
- Configures whether segments that should be deleted are put on a standby list for future use or are released back to the operating system (OS).

0 commit comments

Comments
 (0)