Example usage for java.lang.management MemoryUsage getMax

List of usage examples for java.lang.management MemoryUsage getMax

Introduction

In this page you can find the example usage for java.lang.management MemoryUsage getMax.

Prototype

public long getMax() 

Source Link

Document

Returns the maximum amount of memory in bytes that can be used for memory management.

Usage

From source file:com.attribyte.essem.model.index.IndexStats.java

public String getPercentNonHeapUsed() {
    MemoryUsage usage = mxBean.getNonHeapMemoryUsage();
    return asPercent(RatioGauge.Ratio.of(usage.getUsed(), usage.getMax()).getValue());
}

From source file:com.chinamobile.bcbsp.comm.io.util.MemoryAllocator.java

/** Refresh memory status with current JVM status. */
private void refreshMemoryStatus() {
    MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
    MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage();
    used = memoryUsage.getUsed();//  www  .j av a  2 s . c o m
    committed = memoryUsage.getCommitted();
    maxHeapSize = memoryUsage.getMax();
    remain = maxHeapSize - used;
}

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:org.jahia.modules.serversettings.memoryThread.MemoryThreadInformationManagement.java

public MemoryThreadInformationManagement refresh() {
    MemoryUsage usage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    committedMemory = FileUtils.humanReadableByteCount(usage.getCommitted(), true);
    maxMemory = FileUtils.humanReadableByteCount(usage.getMax(), true);
    usedMemory = FileUtils.humanReadableByteCount(usage.getUsed(), true);
    memoryUsage = Math.round((double) usage.getUsed() / (double) usage.getMax() * 100d);
    return this;
}

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  .jav a2 s. c om
}

From source file:me.doshou.admin.monitor.web.controller.HibernateCacheMonitorController.java

private void setMemoryInfo(Model model) {
    //// w w w . j a v a  2  s .c  om
    MemoryUsage heapMemoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    long usedSystemMemory = heapMemoryUsage.getUsed();
    long maxSystemMemory = heapMemoryUsage.getMax();
    model.addAttribute("usedSystemMemory", usedSystemMemory);
    model.addAttribute("maxSystemMemory", maxSystemMemory);

    //
    Statistics statistics = (Statistics) model.asMap().get("statistics");
    String[] secondLevelCacheRegionNames = statistics.getSecondLevelCacheRegionNames();

    int totalMemorySize = 0;
    int totalMemoryCount = 0;
    int totalDiskCount = 0;

    for (String secondLevelCacheRegionName : secondLevelCacheRegionNames) {
        SecondLevelCacheStatistics secondLevelCacheStatistics = statistics
                .getSecondLevelCacheStatistics(secondLevelCacheRegionName);
        totalMemorySize += secondLevelCacheStatistics.getSizeInMemory();
        totalMemoryCount += secondLevelCacheStatistics.getElementCountInMemory();
        totalDiskCount += secondLevelCacheStatistics.getElementCountOnDisk();
    }

    model.addAttribute("totalMemorySize", totalMemorySize);
    model.addAttribute("totalMemoryCount", totalMemoryCount);
    model.addAttribute("totalDiskCount", totalDiskCount);
}

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 w  ww. j  a  va  2 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:com.all.ultrapeer.UltrapeerMonitor.java

private double getHeapUsage() {
    MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
    MemoryUsage heapMemoryUsage = memoryMXBean.getHeapMemoryUsage();
    return ((double) heapMemoryUsage.getUsed()) / ((double) heapMemoryUsage.getMax()) * 100.0;
}

From source file:com.janrain.backplane.server.metrics.MetricsAccumulator.java

private Map<String, Object> outputJVMUsage() {

    long mb = 1048576;

    Map<String, Object> out = new LinkedHashMap<String, Object>();

    long startTime = ManagementFactory.getRuntimeMXBean().getStartTime();
    int totalLiveThreads = ManagementFactory.getThreadMXBean().getThreadCount();
    double loadAverage = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage();
    MemoryUsage mu = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();

    String startTimeString = BackplaneConfig.ISO8601.format(new Date(startTime));

    out.put("type", "jvm");
    out.put("unit", "mb");
    out.put("heap_used", mu.getUsed() / mb);
    out.put("heap_free", (mu.getMax() - mu.getUsed()) / mb);
    out.put("heap_max", mu.getMax() / mb);
    out.put("jvm_start_time", startTimeString);
    out.put("total_live_threads", totalLiveThreads);
    out.put("load_average_minute", String.format("%2.2f", loadAverage));

    return out;//w w w.jav  a2  s. c o m

}

From source file:com.snowstore.mercury.core.metric.SystemPublicMetrics.java

/**
 * Add JVM heap metrics.//w w w . ja v  a 2  s . c  om
 * 
 * @param result
 *            the result
 */
protected void addHeapMetrics(Collection<Metric<?>> result) {
    MemoryUsage memoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    result.add(new Metric<Long>("heap.committed", memoryUsage.getCommitted() / 1024));
    result.add(new Metric<Long>("heap.init", memoryUsage.getInit() / 1024));
    result.add(new Metric<Long>("heap.used", memoryUsage.getUsed() / 1024));
    result.add(new Metric<Long>("heap", memoryUsage.getMax() / 1024));
}