Here you can find the source of percentMemoryFull()
public static int percentMemoryFull() throws Throwable
//package com.java2s; //License from project: Open Source License public class Main { public static int percentMemoryFull() throws Throwable { System.gc();/*from w w w.j a v a 2 s . c om*/ Runtime r = Runtime.getRuntime(); double free = r.freeMemory(); double total = r.totalMemory(); double used = total - free; double percent = used / total; return (int) (percent * 100.0); } }