< 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:

1575   }
1576 
1577   char model[100];
1578   size = sizeof(model);
1579   int mib_model[] = { CTL_HW, HW_MODEL };
1580   if (sysctl(mib_model, 2, model, &size, NULL, 0) < 0) {
1581     strncpy(model, cpu_arch, sizeof(model));
1582   }
1583 
1584   char machine[100];
1585   size = sizeof(machine);
1586   int mib_machine[] = { CTL_HW, HW_MACHINE };
1587   if (sysctl(mib_machine, 2, machine, &size, NULL, 0) < 0) {
1588       strncpy(machine, "", sizeof(machine));
1589   }
1590 
1591   snprintf(buf, buflen, "%s %s %d MHz", model, machine, mhz);
1592 }
1593 
1594 void os::print_memory_info(outputStream* st) {


1595 
1596   st->print("Memory:");
1597   st->print(" %dk page", os::vm_page_size()>>10);
1598 
1599   st->print(", physical " UINT64_FORMAT "k",
1600             os::physical_memory() >> 10);
1601   st->print("(" UINT64_FORMAT "k free)",
1602             os::available_memory() >> 10);










1603   st->cr();
1604 }
1605 
1606 static void print_signal_handler(outputStream* st, int sig,
1607                                  char* buf, size_t buflen);
1608 
1609 void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
1610   st->print_cr("Signal Handlers:");
1611   print_signal_handler(st, SIGSEGV, buf, buflen);
1612   print_signal_handler(st, SIGBUS , buf, buflen);
1613   print_signal_handler(st, SIGFPE , buf, buflen);
1614   print_signal_handler(st, SIGPIPE, buf, buflen);
1615   print_signal_handler(st, SIGXFSZ, buf, buflen);
1616   print_signal_handler(st, SIGILL , buf, buflen);
1617   print_signal_handler(st, SR_signum, buf, buflen);
1618   print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen);
1619   print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen);
1620   print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen);
1621   print_signal_handler(st, BREAK_SIGNAL, buf, buflen);
1622 }



1575   }
1576 
1577   char model[100];
1578   size = sizeof(model);
1579   int mib_model[] = { CTL_HW, HW_MODEL };
1580   if (sysctl(mib_model, 2, model, &size, NULL, 0) < 0) {
1581     strncpy(model, cpu_arch, sizeof(model));
1582   }
1583 
1584   char machine[100];
1585   size = sizeof(machine);
1586   int mib_machine[] = { CTL_HW, HW_MACHINE };
1587   if (sysctl(mib_machine, 2, machine, &size, NULL, 0) < 0) {
1588       strncpy(machine, "", sizeof(machine));
1589   }
1590 
1591   snprintf(buf, buflen, "%s %s %d MHz", model, machine, mhz);
1592 }
1593 
1594 void os::print_memory_info(outputStream* st) {
1595   xsw_usage swap_usage;
1596   size_t size = sizeof(swap_usage);
1597 
1598   st->print("Memory:");
1599   st->print(" %dk page", os::vm_page_size()>>10);
1600 
1601   st->print(", physical " UINT64_FORMAT "k",
1602             os::physical_memory() >> 10);
1603   st->print("(" UINT64_FORMAT "k free)",
1604             os::available_memory() >> 10);
1605 
1606   if(sysctlbyname("vm.swapusage", &swap_usage, &size, NULL, 0) == 0) {
1607     if (size >= offsetof(xsw_usage, xsu_used)) {
1608       st->print(", swap " UINT64_FORMAT "k",
1609                 ((julong) swap_usage.xsu_total) >> 10);
1610       st->print("(" UINT64_FORMAT "k free)",
1611                 ((julong) swap_usage.xsu_avail) >> 10);
1612     }
1613   }
1614 
1615   st->cr();
1616 }
1617 
1618 static void print_signal_handler(outputStream* st, int sig,
1619                                  char* buf, size_t buflen);
1620 
1621 void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
1622   st->print_cr("Signal Handlers:");
1623   print_signal_handler(st, SIGSEGV, buf, buflen);
1624   print_signal_handler(st, SIGBUS , buf, buflen);
1625   print_signal_handler(st, SIGFPE , buf, buflen);
1626   print_signal_handler(st, SIGPIPE, buf, buflen);
1627   print_signal_handler(st, SIGXFSZ, buf, buflen);
1628   print_signal_handler(st, SIGILL , buf, buflen);
1629   print_signal_handler(st, SR_signum, buf, buflen);
1630   print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen);
1631   print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen);
1632   print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen);
1633   print_signal_handler(st, BREAK_SIGNAL, buf, buflen);
1634 }


< prev index next >