Here you can find the source of usedMemory()
public static long usedMemory()
//package com.java2s; //License from project: Open Source License public class Main { public static long usedMemory() { return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); }//from w w w . jav a 2 s .co m }