Here you can find the source of memoryUsed()
public static long memoryUsed()
//package com.java2s; //License from project: Open Source License public class Main { private static Runtime runtime; public static long memoryUsed() { long mem = 0; for (int i = 0; i < 10; i++) mem += memoryTotal() - memoryFree(); mem /= 10;/*from w w w . ja va2 s . c om*/ return mem; } public static long memoryTotal() { long mem = 0; for (int i = 0; i < 10; i++) mem += runtime.totalMemory(); mem /= 10; return mem; } public static long memoryFree() { long mem = 0; for (int i = 0; i < 10; i++) mem += runtime.freeMemory(); mem /= 10; return mem; } }