List of usage examples for java.lang.management MemoryUsage getCommitted
public long getCommitted()
From source file:com.eurelis.opencms.admin.systeminformation.CmsMemoryOverviewDialog.java
/** * Initializes the infos object.<p> *//*from w ww . java2 s. c o m*/ protected void initInfosObject() { com.sun.management.OperatingSystemMXBean sunOsBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory .getOperatingSystemMXBean(); java.lang.management.OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean(); java.lang.management.ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); java.lang.management.RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); java.lang.management.ClassLoadingMXBean classesBean = ManagementFactory.getClassLoadingMXBean(); for (java.lang.management.MemoryPoolMXBean item : ManagementFactory.getMemoryPoolMXBeans()) { java.lang.management.MemoryUsage mu = item.getUsage(); String name = item.getName(); if (name.toLowerCase().contains("perm")) { setMemPermMax("" + mu.getMax()); setMemPermTotal("" + mu.getCommitted()); setMemPermUsed("" + mu.getUsed()); } else if (name.toLowerCase().contains("old")) { setMemOldMax("" + mu.getMax()); setMemOldTotal("" + mu.getCommitted()); setMemOldUsed("" + mu.getUsed()); } else if (name.toLowerCase().contains("eden")) { setMemEdenMax("" + mu.getMax()); setMemEdenTotal("" + mu.getCommitted()); setMemEdenUsed("" + mu.getUsed()); } else if (name.toLowerCase().contains("survivor")) { setMemSurvivorMax("" + mu.getMax()); setMemSurvivorTotal("" + mu.getCommitted()); setMemSurvivorUsed("" + mu.getUsed()); } else { //LOG.debug("MemoryPoolMXBean name = " + name.toLowerCase()); } } Object o; if (CmsStringUtil.isEmpty(getParamAction())) { o = new CmsAdminSettings(getSession()); } else { // this is not the initial call, get the job object from session o = getDialogObject(); } if (!(o instanceof CmsAdminSettings)) { // create a new history settings handler object m_adminSettings = new CmsAdminSettings(getSession()); } else { // reuse html import handler object stored in session m_adminSettings = (CmsAdminSettings) o; } setParamCloseLink(getJsp() .link("/system/workplace/views/admin/admin-main.jsp?path=/eurelis_system_information/memory.jsp")); }
From source file:com.chinamobile.bcbsp.comm.MessageQueuesForDisk.java
/** Show the information of Memory. */ public void showMemoryInfo() { LOG.info("---------------- Memory Info for Messages ------------------"); MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage(); long used = memoryUsage.getUsed(); long committed = memoryUsage.getCommitted(); LOG.info("<Real> [Memory used] = " + used / MB_SIZE + "MB"); LOG.info("<Real> [Memory committed] = " + committed / MB_SIZE + "MB"); LOG.info("<Evaluate> [size of Message] = " + this.sizeOfMessage + "B"); LOG.info("<Evaluate> [size of Messages Data In Memory] = " + this.sizeOfMessagesDataInMem / MB_SIZE + "MB"); LOG.info("<Evaluate> [size of HashMaps In Memory] = " + this.sizeOfHashMapsInMem / MB_SIZE + "MB"); LOG.info("<Evaluate> [size of Messages Data Threshold] = " + this.sizeThreshold / MB_SIZE + "MB"); LOG.info(//from ww w . j a v a 2 s . co m "<Evaluate> [count of Messages Data In Memory] = " + this.countOfMessagesDataInMem / KB_SIZE + "K"); LOG.info("<Evaluate> [count of Messages Data Threshold] = " + this.countThreshold / KB_SIZE + "K"); LOG.info("----------------- ------------------------ -----------------"); // showHashBucketsInfo(); }
From source file:org.apache.flink.runtime.taskmanager.TaskManager.java
private String getMemoryUsageStatsAsString(MemoryMXBean memoryMXBean) { MemoryUsage heap = memoryMXBean.getHeapMemoryUsage(); MemoryUsage nonHeap = memoryMXBean.getNonHeapMemoryUsage(); int mb = 20;//from w ww .j a v a2 s . c o m long heapUsed = heap.getUsed() >> mb; long heapCommitted = heap.getCommitted() >> mb; long heapMax = heap.getMax() >> mb; long nonHeapUsed = nonHeap.getUsed() >> mb; long nonHeapCommitted = nonHeap.getCommitted() >> mb; long nonHeapMax = nonHeap.getMax() >> mb; String msg = String.format( "Memory usage stats: [HEAP: %d/%d/%d MB, NON HEAP: %d/%d/%d MB (used/comitted/max)]", heapUsed, heapCommitted, heapMax, nonHeapUsed, nonHeapCommitted, nonHeapMax); return msg; }
From source file:net.centro.rtb.monitoringcenter.metrics.system.jvm.JvmMemoryUsageMetricSet.java
JvmMemoryUsageMetricSet(final MemoryUsageProvider memoryUsageProvider) { Preconditions.checkNotNull(memoryUsageProvider); final MemoryUsage memoryUsage = memoryUsageProvider.get(); Preconditions.checkNotNull(memoryUsage); Map<String, Metric> metricsByNames = new HashMap<>(); if (memoryUsage.getInit() >= 0) { this.initialSizeInBytesGauge = new Gauge<Long>() { @Override//w w w .j a v a2 s . c o m public Long getValue() { return memoryUsageProvider.get().getInit(); } }; metricsByNames.put("initialInBytes", initialSizeInBytesGauge); } this.usedMemoryInBytesGauge = new Gauge<Long>() { @Override public Long getValue() { return memoryUsageProvider.get().getUsed(); } }; metricsByNames.put("usedInBytes", usedMemoryInBytesGauge); if (memoryUsage.getMax() >= 0) { this.maxAvailableMemoryInBytesGauge = new Gauge<Long>() { @Override public Long getValue() { return memoryUsageProvider.get().getMax(); } }; metricsByNames.put("maxAvailableInBytes", maxAvailableMemoryInBytesGauge); } this.committedMemoryInBytesGauge = new Gauge<Long>() { @Override public Long getValue() { return memoryUsageProvider.get().getCommitted(); } }; metricsByNames.put("committedInBytes", committedMemoryInBytesGauge); this.usedMemoryPercentageGauge = new Gauge<Double>() { @Override public Double getValue() { MemoryUsage memoryUsage = memoryUsageProvider.get(); long max = memoryUsage.getMax() > 0 ? memoryUsage.getMax() : memoryUsage.getCommitted(); return Double.valueOf(memoryUsage.getUsed()) / max * 100; } }; metricsByNames.put("usedPercentage", usedMemoryPercentageGauge); this.metricsByNames = metricsByNames; }