< prev index next >

src/hotspot/os/bsd/os_bsd.cpp

Print this page
rev 54246 : 8221325: Add information about swap space to print_memory_info() on MacOS
Summary: Added swap space information on MacOS
Reviewed-by:

@@ -1590,18 +1590,30 @@
 
   snprintf(buf, buflen, "%s %s %d MHz", model, machine, mhz);
 }
 
 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);
 
   st->print(", physical " UINT64_FORMAT "k",
             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();
 }
 
 static void print_signal_handler(outputStream* st, int sig,
                                  char* buf, size_t buflen);
< prev index next >