# HG changeset patch # User mbaesken # Date 1527085589 -7200 # Node ID a11c1cb542bbd1671d25b85efe7d09b983c48525 # Parent ff5d0ea58d9b4d494f57d1c145bca2dd87389a5a 8202427: Enhance os::print_memory_info on Windows Reviewed-by: goetz, stuefe diff -r ff5d0ea58d9b -r a11c1cb542bb src/hotspot/os/windows/os_windows.cpp --- a/src/hotspot/os/windows/os_windows.cpp Wed Mar 21 16:03:12 2018 +0100 +++ b/src/hotspot/os/windows/os_windows.cpp Wed May 23 16:26:29 2018 +0200 @@ -1745,13 +1745,46 @@ // value if total memory is larger than 4GB MEMORYSTATUSEX ms; ms.dwLength = sizeof(ms); - GlobalMemoryStatusEx(&ms); - - st->print(", physical %uk", os::physical_memory() >> 10); - st->print("(%uk free)", os::available_memory() >> 10); - - st->print(", swap %uk", ms.ullTotalPageFile >> 10); - st->print("(%uk free)", ms.ullAvailPageFile >> 10); + int r1 = GlobalMemoryStatusEx(&ms); + + if (r1 != 0) { + st->print(", system-wide physical " INT64_FORMAT "M ", + (int64_t) ms.ullTotalPhys >> 20); + st->print("(" INT64_FORMAT "M free)\n", (int64_t) ms.ullAvailPhys >> 20); + + st->print("TotalPageFile size " INT64_FORMAT "M ", + (int64_t) ms.ullTotalPageFile >> 20); + st->print("(AvailPageFile size " INT64_FORMAT "M)", + (int64_t) ms.ullAvailPageFile >> 20); + + // on 32bit Total/AvailVirtual are interesting (show us how close we get to 2-4 GB per process borders) +#if defined(_M_IX86) + st->print(", user-mode portion of virtual address-space " INT64_FORMAT "M ", + (int64_t) ms.ullTotalVirtual >> 20); + st->print("(" INT64_FORMAT "M free)", (int64_t) ms.ullAvailVirtual >> 20); +#endif + } else { + st->print(", GlobalMemoryStatusEx did not succeed so we miss some memory values."); + } + + // extended memory statistics for a process + PROCESS_MEMORY_COUNTERS_EX pmex; + ZeroMemory(&pmex, sizeof(PROCESS_MEMORY_COUNTERS_EX)); + pmex.cb = sizeof(pmex); + int r2 = GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*) &pmex, sizeof(pmex)); + + if (r2 != 0) { + st->print("\ncurrent process WorkingSet (physical memory assigned to process): " INT64_FORMAT "M, ", + (int64_t) pmex.WorkingSetSize >> 20); + st->print("peak: " INT64_FORMAT "M\n", (int64_t) pmex.PeakWorkingSetSize >> 20); + + st->print("current process commit charge (\"private bytes\"): " INT64_FORMAT "M, ", + (int64_t) pmex.PrivateUsage >> 20); + st->print("peak: " INT64_FORMAT "M", (int64_t) pmex.PeakPagefileUsage >> 20); + } else { + st->print("\nGetProcessMemoryInfo did not succeed so we miss some memory values."); + } + st->cr(); }