Here you can find the source of showMemoryInfo()
public static void showMemoryInfo()
//package com.java2s; public class Main { public static void showMemoryInfo() { final Runtime runtime = Runtime.getRuntime(); final long maxMemory = runtime.maxMemory(); final long allocatedMemory = runtime.totalMemory(); final long freeMemory = runtime.freeMemory(); System.out.println("------------------------------------------------------"); System.out.println("free memory: " + (freeMemory / 1024.0 / 1024.0) + " Mb"); System.out.println("allocated memory: " + (allocatedMemory / 1024.0 / 1024.0) + " Mb"); System.out.println("max memory: " + (maxMemory / 1024.0 / 1024.0) + " Mb"); System.out.println(//from w ww .j a v a 2s. co m "total free memory: " + (freeMemory + (maxMemory - allocatedMemory)) / 1024.0 / 1024.0 + " Mb"); System.out.println("------------------------------------------------------"); } }