# HG changeset patch # User rschmelter # Date 1553257398 25200 # Fri Mar 22 05:23:18 2019 -0700 # Node ID c17dd6ddc90e9ff12f678bfc44d87a2f192be2e6 # Parent 96c45aa6105654bf5c06e983cbbfdc94de8a844f 8221325: Add information about swap space to print_memory_info() on MacOS Summary: Added swap space information on MacOS Reviewed-by: diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -1592,6 +1592,8 @@ } void os::print_memory_info(outputStream* st) { + xsw_usage swap_usage; + size_t size = sizeof(swap_usage); st->print("Memory:"); st->print(" %dk page", os::vm_page_size()>>10); @@ -1600,6 +1602,16 @@ os::physical_memory() >> 10); st->print("(" UINT64_FORMAT "k free)", os::available_memory() >> 10); + + if(sysctlbyname("vm.swapusage", &swap_usage, &size, NULL, 0) == 0) { + if (size >= offsetof(xsw_usage, xsu_used)) { + st->print(", swap " UINT64_FORMAT "k", + ((julong) swap_usage.xsu_total) >> 10); + st->print("(" UINT64_FORMAT "k free)", + ((julong) swap_usage.xsu_avail) >> 10); + } + } + st->cr(); }