Example usage for java.lang.management MemoryUsage getInit

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

Introduction

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

Prototype

public long getInit() 

Source Link

Document

Returns the amount of memory in bytes that the Java virtual machine initially requests from the operating system for memory management.

Usage

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  ww  .  java  2  s .co m
    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.romaframework.core.config.RomaApplicationContext.java

private void logMemoryUsage() {
    MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();
    MemoryUsage heapMemory = memBean.getHeapMemoryUsage();
    MemoryUsage nonHeapMemory = memBean.getNonHeapMemoryUsage();

    NumberFormat nf = NumberFormat.getInstance();
    log.info("--------------- MEMORY USAGE ---------------");
    log.info("HEAP INIT MEMORY:       " + nf.format(heapMemory.getInit()) + " bytes");
    log.info("HEAP USED MEMORY:       " + nf.format(heapMemory.getUsed()) + " bytes");
    log.info("HEAP COMMITTED MEMORY:  " + nf.format(heapMemory.getCommitted()) + " bytes");
    log.info("HEAP MAX MEMORY:        " + nf.format(heapMemory.getMax()) + " bytes");
    log.info(" ");
    log.info("NON HEAP INIT MEMORY:       " + nf.format(nonHeapMemory.getInit()) + " bytes");
    log.info("NON HEAP USED MEMORY:       " + nf.format(nonHeapMemory.getUsed()) + " bytes");
    log.info("NON HEAP COMMITTED MEMORY:  " + nf.format(nonHeapMemory.getCommitted()) + " bytes");
    log.info("NON HEAP MAX MEMORY:        " + nf.format(nonHeapMemory.getMax()) + " bytes");
    log.info("--------------------------------------------");
}