Add config knob to the gc to control its concept of what total physical memory is...
authorDavid Wrighton <davidwr@microsoft.com>
Wed, 5 Feb 2020 17:57:16 +0000 (09:57 -0800)
committerGitHub <noreply@github.com>
Wed, 5 Feb 2020 17:57:16 +0000 (09:57 -0800)
- The GC relies on the VM to compute this number normally, but the runtime uses heuristics which may be undesirable for the customer scenario (especially inside of a Windows Job object)
- This knob provides a way for the customer to override the heuristics

src/coreclr/src/gc/gc.cpp
src/coreclr/src/gc/gcconfig.h

index 873287fc4cb242c33fb915b13f0fed8a82c3406b..63598a3fa34b2e27664fd0818565b99cb60d5ceb 100644 (file)
@@ -36219,7 +36219,11 @@ HRESULT GCHeap::Initialize()
 #endif //TRACE_GC
 
     bool is_restricted;
-    gc_heap::total_physical_mem = GCToOSInterface::GetPhysicalMemoryLimit (&is_restricted);
+    gc_heap::total_physical_mem = (size_t)GCConfig::GetGCTotalPhysicalMemory();
+    if (!(gc_heap::total_physical_mem))
+    {
+        gc_heap::total_physical_mem = GCToOSInterface::GetPhysicalMemoryLimit (&is_restricted);
+    }
 
 #ifdef HOST_64BIT
     gc_heap::heap_hard_limit = (size_t)GCConfig::GetGCHeapHardLimit();
index ba8db0f77af91182b92ac8712252d652c9684b94..4d1aa429652b0bd13a5235e43dc631e6d09fb94e 100644 (file)
@@ -121,6 +121,8 @@ public:
         "Specifies a hard limit for the GC heap")                                                \
     INT_CONFIG(GCHeapHardLimitPercent, "GCHeapHardLimitPercent", 0,                              \
         "Specifies the GC heap usage as a percentage of the total memory")                       \
+    INT_CONFIG(GCTotalPhysicalMemory, "GCTotalPhysicalMemory", 0,                                \
+        "Specifies what the GC should consider to be total physical memory")                     \
     STRING_CONFIG(LogFile,    "GCLogFile",    "Specifies the name of the GC log file")           \
     STRING_CONFIG(ConfigLogFile, "GCConfigLogFile",                                              \
         "Specifies the name of the GC config log file")                                          \