Here you can find the source of memoryUsage()
public static String memoryUsage()
//package com.java2s; //License from project: Apache License public class Main { public static String memoryUsage() { Runtime r = Runtime.getRuntime(); long used = r.totalMemory() - r.freeMemory(); return "usedHeap=" + (used / 1000000) + "MB, percent=" + (100.0 * used / r.maxMemory()); }/*from w w w. j av a 2 s .co m*/ }