# HG changeset patch # User rschmelter # Date 1553589966 25200 # Node ID 724b9e361cb6c1aa6f3ace0115d873f82e99636c # Parent 5c7418757badaecada7f68d9c6461af43edbd13a 8221325: Add information about swap space to print_memory_info() on MacOS Reviewed-by: stuefe, dholmes diff -r 5c7418757bad -r 724b9e361cb6 src/hotspot/os/bsd/os_bsd.cpp --- a/src/hotspot/os/bsd/os_bsd.cpp Wed Apr 03 20:39:19 2019 -0400 +++ b/src/hotspot/os/bsd/os_bsd.cpp Tue Mar 26 01:46:06 2019 -0700 @@ -1598,6 +1598,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); @@ -1606,6 +1608,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) || (errno == ENOMEM)) { + if (size >= offset_of(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(); }