List of usage examples for java.lang.management ManagementFactory getMemoryMXBean
public static MemoryMXBean getMemoryMXBean()
From source file:ro.nextreports.server.web.debug.InfoUtil.java
public static List<Info> getGeneralJVMInfo() { List<Info> infos = new ArrayList<Info>(); RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); infos.add(new Info("uptime", "" + Duration.milliseconds(runtimeBean.getUptime()).toString())); infos.add(new Info("name", runtimeBean.getName())); infos.add(new Info("pid", runtimeBean.getName().split("@")[0])); OperatingSystemMXBean systemBean = ManagementFactory.getOperatingSystemMXBean(); infos.add(new Info("os name", "" + systemBean.getName())); infos.add(new Info("os version", "" + systemBean.getVersion())); infos.add(new Info("system load average", "" + systemBean.getSystemLoadAverage())); infos.add(new Info("available processors", "" + systemBean.getAvailableProcessors())); ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); infos.add(new Info("thread count", "" + threadBean.getThreadCount())); infos.add(new Info("peak thread count", "" + threadBean.getPeakThreadCount())); MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean(); infos.add(new Info("heap memory used", FileUtils.byteCountToDisplaySize(memoryBean.getHeapMemoryUsage().getUsed()))); infos.add(new Info("non-heap memory used", FileUtils.byteCountToDisplaySize(memoryBean.getNonHeapMemoryUsage().getUsed()))); return infos; }