Skip to content

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

Closed

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

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Apr 1, 2023
  2. mangod9 commented on Apr 1, 2023

    @mangod9
    Member

    @mrsharm can you take a look at this?

  3. removed
    untriagedNew issue has not been triaged by the area owner
    on Apr 1, 2023
  4. added this to the 8.0.0 milestone on Apr 1, 2023
  5. mrsharm commented on Apr 1, 2023

    @mrsharm
    Contributor

    Yes, taking a look. I was able to repro. I will have a fix soon.

  6. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Apr 1, 2023
  7. asrichesson commented on Apr 1, 2023

    @asrichesson
    Author

    Looks like System.GC.RetainVM is also not being set.

  8. added a commit that references this issue on Apr 6, 2023
    ca3273b
  9. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Apr 6, 2023
  10. ghost locked as resolved and limited conversation to collaborators on May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions