8202427: Enhance os::print_memory_info on Windows

Reviewed-by: goetz, stuefe
This commit is contained in:
Matthias Baesken 2018-05-23 16:26:29 +02:00
parent ac9f93a147
commit de1b886368

View File

@ -1745,13 +1745,46 @@ void os::print_memory_info(outputStream* st) {
// value if total memory is larger than 4GB
MEMORYSTATUSEX ms;
ms.dwLength = sizeof(ms);
GlobalMemoryStatusEx(&ms);
int r1 = GlobalMemoryStatusEx(&ms);
st->print(", physical %uk", os::physical_memory() >> 10);
st->print("(%uk free)", os::available_memory() >> 10);
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->print(", swap %uk", ms.ullTotalPageFile >> 10);
st->print("(%uk free)", ms.ullAvailPageFile >> 10);
st->cr();
}