List of usage examples for java.lang.management MemoryPoolMXBean getCollectionUsage
public MemoryUsage getCollectionUsage();
From source file:io.ecarf.core.utils.Utils.java
/** * Log memory usage//from w ww. java 2 s . c o m * @return */ public static long getMemoryUsage() { List<MemoryPoolMXBean> memoryPools = new ArrayList<MemoryPoolMXBean>( ManagementFactory.getMemoryPoolMXBeans()); long usedHeapMemoryAfterLastGC = 0; for (MemoryPoolMXBean memoryPool : memoryPools) { if (memoryPool.getType().equals(MemoryType.HEAP)) { MemoryUsage poolCollectionMemoryUsage = memoryPool.getCollectionUsage(); usedHeapMemoryAfterLastGC += poolCollectionMemoryUsage.getUsed(); } } return usedHeapMemoryAfterLastGC; }
From source file:org.mifos.framework.ApplicationInitializer.java
private void printMemoryPool() { logger.info("Memory MXBean"); logger.info("Heap Memory Usage: " + ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()); logger.info("Non-Heap Memory Usage: " + ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage()); logger.info("-----Memory Pool MXBeans------"); Iterator<MemoryPoolMXBean> iter = ManagementFactory.getMemoryPoolMXBeans().iterator(); while (iter.hasNext()) { MemoryPoolMXBean item = iter.next(); logger.info("Name: " + item.getName()); logger.info("Type: " + item.getType()); logger.info("Usage: " + item.getUsage()); logger.info("Peak Usage: " + item.getPeakUsage()); logger.info("Collection Usage: " + item.getCollectionUsage()); logger.info("+++++++++++++++++++"); }//from w w w. j av a 2 s .c o m }