Skip to content

GC.GetConfigurationVariables() not respecting "System.GC.HighMemoryPercent" #84198

Description

@asrichesson

Description

I'm trying to set the garbage collection properties in a runtimeconfig.template.json file, following the documentation in Garbage collector config settings.
But not all my settings are being picked up, including System.GC.HighMemoryPercent. However, some properties like System.GC.HeapHardLimit are being picked up.

I'm not sure whether my settings are invalid, the documentation is wrong, or the GC.GetConfigurationVariables() isn't returning the actual config values.

Reproduction Steps

I have the following runtimeconfig.template.json file in a .net 7 console application. I have no related environment variables set.

{
  "configProperties": {
    "System.GC.HighMemoryPercent": 75,
    "System.GC.LOHThreshold": 120000,
    "System.GC.Server": true,
    "System.GC.RetainVM": true,
    "System.GC.HeapHardLimit": 209715201,
    "System.GC.Concurrent": true,
    "System.GC.HeapCount": 9
  }
}
var gcConfig = GC.GetConfigurationVariables();

foreach (var kvp in gcConfig)
{
    Console.WriteLine(kvp.Key + ":" + kvp.Value);
}
ServerGC:True
ConcurrentGC:True
RetainVM:False
NoAffinitize:False
GCCpuGroup:False
GCLargePages:False
HeapCount:9
GCHeapAffinitizeMask:0
GCHeapAffinitizeRanges:
GCHighMemPercent:0
GCHeapHardLimit:209715201
GCHeapHardLimitPercent:0
GCHeapHardLimitSOH:0
GCHeapHardLimitLOH:0
GCHeapHardLimitPOH:0
GCHeapHardLimitSOHPercent:0
GCHeapHardLimitLOHPercent:0
GCHeapHardLimitPOHPercent:0
GCConserveMem:0
GCName:

GCProgram.zip

Expected behavior

I should expect to see the following included in the program output.

GCHighMemPercent:75

Actual behavior

GCHighMemPercent:0

Regression?

No response

Known Workarounds

Setting the DOTNET_GCHighMemPercent env variable didn't seem to work either.

Configuration

.net7, windows 11, x64

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions