private void checkMemory(RoutingContext routingContext) {
    OperatingSystemMXBean bean =
        (OperatingSystemMXBean) ManagementFactoryHelper.getOperatingSystemMXBean();
    long max = bean.getTotalPhysicalMemorySize();
    long free = bean.getFreePhysicalMemorySize();

    routingContext
        .response()
        .putHeader("Content-Type", "text/plain")
        .setStatusCode(HttpResponseStatus.OK.code())
        .end(String.valueOf(max - free));
  }
示例#2
0
 /**
  * Returns the managed bean for the operating system on which the Java virtual machine is running.
  *
  * @return an {@link OperatingSystemMXBean} object for the Java virtual machine.
  */
 public static OperatingSystemMXBean getOperatingSystemMXBean() {
   return ManagementFactoryHelper.getOperatingSystemMXBean();
 }