List of usage examples for java.lang.management MemoryUsage getCommitted
public long getCommitted()
From source file:com.chinamobile.bcbsp.comm.io.util.MemoryAllocator.java
/** Show the information of memory used. */ public void PrintMemoryInfo(Log LOG) { MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage(); long usedNow = memoryUsage.getUsed(); long committedNow = memoryUsage.getCommitted(); long maxHeapSizeNow = memoryUsage.getMax(); long remainNow = maxHeapSize - used; LOG.info("Memory Usage **********************************************"); LOG.info("Memory Max ****************** " + maxHeapSizeNow); LOG.info("Memory Commit **************** " + committedNow + "-----Percents: " + committedNow * 1.0f / maxHeapSizeNow); LOG.info("Memory Used ****************** " + usedNow + "-----Percents: " + usedNow * 1.0f / maxHeapSizeNow); LOG.info("Memory Remain **************** " + remainNow + "-----Percents: " + remainNow * 1.0f / maxHeapSizeNow); }
From source file:com.snowstore.mercury.core.metric.SystemPublicMetrics.java
/** * Add JVM heap metrics.//ww w. jav a 2 s . co m * * @param result * the result */ protected void addNoHeapMetrics(Collection<Metric<?>> result) { MemoryUsage memoryUsage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage(); result.add(new Metric<Long>("noheap.committed", memoryUsage.getCommitted() / 1024)); result.add(new Metric<Long>("noheap.init", memoryUsage.getInit() / 1024)); result.add(new Metric<Long>("noheap.used", memoryUsage.getUsed() / 1024)); result.add(new Metric<Long>("noheap", memoryUsage.getMax() / 1024)); }
From source file:com.thoughtworks.go.server.service.support.ServerRuntimeInformationProvider.java
private String format(MemoryUsage memoryUsage) { long init = memoryUsage.getInit(); long used = memoryUsage.getUsed(); long committed = memoryUsage.getCommitted(); long max = memoryUsage.getMax(); return String.format(" init: %s\n used: %s\n committed: %s\n max: %s\n", init, used, committed, max);/*from w w w . j a v a 2 s . com*/ }
From source file:org.craftercms.commons.monitoring.MemoryMonitor.java
/** * Private Constructor of the MemoryMonitor POJO * @param memName Type of MemoryMonitor to get the information. * @param memoryUsage {@link MemoryUsage} bean where the information is taken from. *//*from ww w.j ava2 s . c o m*/ private MemoryMonitor(String memName, MemoryUsage memoryUsage) { this.name = memName; this.init = FileUtils.byteCountToDisplaySize(memoryUsage.getInit()); this.used = FileUtils.byteCountToDisplaySize(memoryUsage.getUsed()); this.committed = FileUtils.byteCountToDisplaySize(memoryUsage.getCommitted()); this.max = FileUtils.byteCountToDisplaySize(memoryUsage.getMax()); }
From source file:org.artifactory.webapp.wicket.page.config.advanced.SystemInfoPage.java
/** * Return a formatted string of the system info to display * * @return//from w w w.ja va 2s .c om */ private String collectSystemInfo() { StringBuilder infoBuilder = new StringBuilder(); StorageProperties storageProperties = ContextHelper.get().beanForType(StorageProperties.class); infoBuilder.append("Storage Info:").append("\n"); addInfo(infoBuilder, "Database Type", storageProperties.getDbType().toString()); BinaryProviderType binariesStorageType = storageProperties.getBinariesStorageType(); addInfo(infoBuilder, "Storage Type", binariesStorageType.toString()); if (BinaryProviderType.S3 == binariesStorageType) { // S3 properties addInfo(infoBuilder, "s3.bucket.name", storageProperties.getS3BucketName()); addInfo(infoBuilder, "s3.bucket.path", storageProperties.getS3BucketPath()); addInfo(infoBuilder, "s3.endpoint", storageProperties.getS3Entpoint()); // Retry properties addInfo(infoBuilder, "retry.max.retries.number", Integer.toString(storageProperties.getMaxRetriesNumber())); addInfo(infoBuilder, "retry.delay.between.retries", Integer.toString(storageProperties.getDelayBetweenRetries())); // Eventually persisted properties addInfo(infoBuilder, "eventually.persisted.max.number.of.threads", Integer.toString(storageProperties.getEventuallyPersistedMaxNumberOfThread())); addInfo(infoBuilder, "eventually.persisted.timeout", Integer.toString(storageProperties.getEventuallyPersistedTimeOut())); addInfo(infoBuilder, "eventually.dispatcher.sleep.time", Long.toString(storageProperties.getEventuallyPersistedDispatcherSleepTime())); } infoBuilder.append("\n").append("System Properties:").append("\n"); Properties properties = System.getProperties(); //// add Artifactory version to the properties, will be alphabetically sorted later. properties.setProperty(ConstantValues.artifactoryVersion.getPropertyName(), ConstantValues.artifactoryVersion.getString()); AddonsManager addonsManager = ContextHelper.get().beanForType(AddonsManager.class); addInfo(infoBuilder, "artifactory.running.mode", addonsManager.getArtifactoryRunningMode().name()); addInfo(infoBuilder, "artifactory.running.state", ContextHelper.get().isOffline() ? "Offline" : "Online"); addFromProperties(infoBuilder, properties); addHaProperties(infoBuilder); infoBuilder.append("\n").append("General JVM Info:").append("\n"); OperatingSystemMXBean systemBean = ManagementFactory.getOperatingSystemMXBean(); addInfo(infoBuilder, "Available Processors", Integer.toString(systemBean.getAvailableProcessors())); MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean(); MemoryUsage heapMemoryUsage = memoryBean.getHeapMemoryUsage(); addInfo(infoBuilder, "Heap Memory Usage-Committed", Long.toString(heapMemoryUsage.getCommitted())); addInfo(infoBuilder, "Heap Memory Usage-Init", Long.toString(heapMemoryUsage.getInit())); addInfo(infoBuilder, "Heap Memory Usage-Max", Long.toString(heapMemoryUsage.getMax())); addInfo(infoBuilder, "Heap Memory Usage-Used", Long.toString(heapMemoryUsage.getUsed())); MemoryUsage nonHeapMemoryUsage = memoryBean.getNonHeapMemoryUsage(); addInfo(infoBuilder, "Non-Heap Memory Usage-Committed", Long.toString(nonHeapMemoryUsage.getCommitted())); addInfo(infoBuilder, "Non-Heap Memory Usage-Init", Long.toString(nonHeapMemoryUsage.getInit())); addInfo(infoBuilder, "Non-Heap Memory Usage-Max", Long.toString(nonHeapMemoryUsage.getMax())); addInfo(infoBuilder, "Non-Heap Memory Usage-Used", Long.toString(nonHeapMemoryUsage.getUsed())); RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean(); StringBuilder vmArgumentBuilder = new StringBuilder(); List<String> vmArguments = RuntimemxBean.getInputArguments(); if (vmArguments != null) { for (String vmArgument : vmArguments) { if (InfoWriter.shouldMaskValue(vmArgument)) { vmArgument = Strings.maskKeyValue(vmArgument); } vmArgumentBuilder.append(vmArgument); if (vmArguments.indexOf(vmArgument) != (vmArguments.size() - 1)) { vmArgumentBuilder.append("\n"); } } } infoBuilder.append("\nJVM Arguments:\n").append(vmArgumentBuilder.toString()); return StringUtils.removeEnd(infoBuilder.toString(), "\n"); }
From source file:org.rhq.enterprise.agent.promptcmd.GCPromptCommand.java
private void printMemoryUsage(PrintWriter out, String name, MemoryType type, MemoryUsage memUsage) { long init = memUsage.getInit(); long max = memUsage.getMax(); long used = memUsage.getUsed(); long committed = memUsage.getCommitted(); String typeStr;// w w w .java 2 s .c om switch (type) { case HEAP: typeStr = "Heap"; break; case NON_HEAP: typeStr = "Non-heap"; break; default: typeStr = "?"; } double usedPercentage = (used * 100.0) / committed; double committedPercentage = (committed * 100.0) / max; out.println(MSG.getMsg(AgentI18NResourceKeys.GC_MEM_USAGE, name, typeStr, init, max, used, usedPercentage, committed, committedPercentage)); }
From source file:org.uncommons.watchmaker.swing.evolutionmonitor.JVMView.java
private void addMemoryDataPoint() { MemoryUsage heapUsage = memoryBean.getHeapMemoryUsage(); double usedMegabytes = (double) heapUsage.getUsed() / MEGABYTE; Second second = new Second(); memoryUsageSeries.add(second, usedMegabytes); heapSizeSeries.add(second, (double) heapUsage.getCommitted() / MEGABYTE); }
From source file:org.apache.jxtadoop.metrics.jvm.JvmMetrics.java
private void doMemoryUpdates() { MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); MemoryUsage memNonHeap = memoryMXBean.getNonHeapMemoryUsage(); MemoryUsage memHeap = memoryMXBean.getHeapMemoryUsage(); metrics.setMetric("memNonHeapUsedM", memNonHeap.getUsed() / M); metrics.setMetric("memNonHeapCommittedM", memNonHeap.getCommitted() / M); metrics.setMetric("memHeapUsedM", memHeap.getUsed() / M); metrics.setMetric("memHeapCommittedM", memHeap.getCommitted() / M); }
From source file:VerboseGC.java
/** * Prints the verbose GC log to System.out to list the memory usage of all * memory pools as well as the GC statistics. *//*from ww w.j av a2s.co m*/ public void printVerboseGc() { System.out.print("Uptime: " + formatMillis(rmbean.getUptime())); for (GarbageCollectorMXBean gc : gcmbeans) { System.out.print(" [" + gc.getName() + ": "); System.out.print("Count=" + gc.getCollectionCount()); System.out.print(" GCTime=" + formatMillis(gc.getCollectionTime())); System.out.print("]"); } System.out.println(); for (MemoryPoolMXBean p : pools) { System.out.print(" [" + p.getName() + ":"); MemoryUsage u = p.getUsage(); System.out.print(" Used=" + formatBytes(u.getUsed())); System.out.print(" Committed=" + formatBytes(u.getCommitted())); System.out.println("]"); } }
From source file:mondrian.util.UtilCompatibleJdk15.java
public Util.MemoryInfo getMemoryInfo() { return new Util.MemoryInfo() { protected final MemoryPoolMXBean TENURED_POOL = findTenuredGenPool(); public Util.MemoryInfo.Usage get() { final MemoryUsage memoryUsage = TENURED_POOL.getUsage(); return new Usage() { public long getUsed() { return memoryUsage.getUsed(); }//ww w . jav a 2 s . com public long getCommitted() { return memoryUsage.getCommitted(); } public long getMax() { return memoryUsage.getMax(); } }; } }; }