Here you can find the source of showMemoryUsage()
public static void showMemoryUsage()
//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 }