Java Memory Information printMemory()

Here you can find the source of printMemory()

Description

print Memory

License

Open Source License

Declaration

public static void printMemory() 

Method Source Code

//package com.java2s;

public class Main {
    public static void printMemory() {

        int mb = 1024 * 1024;

        //Getting the runtime reference from system
        Runtime runtime = Runtime.getRuntime();

        System.out.println("##### Heap utilization statistics [MB] #####");

        //Print used memory
        System.out.println("Used Memory:" + (runtime.totalMemory() - runtime.freeMemory()) / mb);

        //Print free memory
        System.out.println("Free Memory:" + runtime.freeMemory() / mb);

        //Print total available memory
        System.out.println("Total Memory:" + runtime.totalMemory() / mb);

        //Print Maximum available memory
        System.out.println("Max Memory:" + runtime.maxMemory() / mb);
    }//from   w ww . j ava  2 s  .  c  o  m
}

Related

  1. parseMemory(String s, int def)
  2. parseMemorySize(String arg)
  3. prettyPrintMemory(long size, boolean includeSpace)
  4. prettyPrintMemoryPerSecond(long rate)
  5. printMemory()
  6. printMemory(String label)
  7. printMemory(String str)
  8. printMemoryInfo()
  9. printMemoryInstruction(byte[] instruction)