Java Memory Usage showMemoryUsage()

Here you can find the source of showMemoryUsage()

Description

show Memory Usage

License

Open Source License

Declaration

public static void showMemoryUsage() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static void showMemoryUsage() {
        Runtime runtime = Runtime.getRuntime();

        long maxMemory = runtime.maxMemory();
        long allocatedMemory = runtime.totalMemory();
        long freeMemory = runtime.freeMemory();

        System.out.println("-- MEMORY USAGE -----------------");
        System.out.println("-- free memory: " + freeMemory / 1024);
        System.out.println("-- allocated memory: " + allocatedMemory / 1024);
        System.out.println("-- max memory: " + maxMemory / 1024);
        System.out.println("-- total free memory: " + (freeMemory + (maxMemory - allocatedMemory)) / 1024);
        System.out.println("---------------------------------");
    }//www. j  ava  2  s  . c  o m
}

Related

  1. memoryUsage()
  2. memoryUsage()
  3. memoryUsage()
  4. printMemoryUsage()
  5. reportMemoryUsage()