From 3ff82040ea7be4f8c260b237690f2f0553c7cac6 Mon Sep 17 00:00:00 2001 From: David Mason Date: Fri, 19 Oct 2018 17:41:25 -0700 Subject: [PATCH] Local GC - Fix GCToOSInterface::GetPhysicalMemoryLimit (#20495) We weren't setting memStatus->dwLength so the call to GlobalMemoryStatusEx would fail and we would return 0. This caused the standalone GC to get in to a state where we wouldn't allocate more memory for the GC heap even if there was plenty available on the machine. --- src/gc/windows/gcenv.windows.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/gc/windows/gcenv.windows.cpp b/src/gc/windows/gcenv.windows.cpp index 798c1ba..fbaa8a5 100644 --- a/src/gc/windows/gcenv.windows.cpp +++ b/src/gc/windows/gcenv.windows.cpp @@ -935,12 +935,9 @@ uint32_t GCToOSInterface::GetCurrentProcessCpuCount() size_t GCToOSInterface::GetVirtualMemoryLimit() { MEMORYSTATUSEX memStatus; - if (::GlobalMemoryStatusEx(&memStatus)) - { - return (size_t)memStatus.ullAvailVirtual; - } - - return 0; + GetProcessMemoryLoad(&memStatus); + assert(memStatus.ullAvailVirtual != 0); + return (size_t)memStatus.ullAvailVirtual; } // Get the physical memory that this process can use. @@ -956,12 +953,9 @@ uint64_t GCToOSInterface::GetPhysicalMemoryLimit() return restricted_limit; MEMORYSTATUSEX memStatus; - if (::GlobalMemoryStatusEx(&memStatus)) - { - return memStatus.ullTotalPhys; - } - - return 0; + GetProcessMemoryLoad(&memStatus); + assert(memStatus.ullTotalPhys != 0); + return memStatus.ullTotalPhys; } // Get memory status -- 2.7.4