Here you can find the source of printMemoryInfo()
public static void printMemoryInfo()
//package com.java2s; //License from project: Apache License public class Main { /**/*from w ww . j a va 2 s . co m*/ * Print memory info */ public static void printMemoryInfo() { Runtime currRuntime = Runtime.getRuntime(); int nFreeMemory = (int) (currRuntime.freeMemory() / 1024 / 1024); int nTotalMemory = (int) (currRuntime.totalMemory() / 1024 / 1024); String message = nFreeMemory + "M/" + nTotalMemory + "M(free/total)"; System.out.println("memory:" + message); } }