Here you can find the source of getFreeMemory()
public static int getFreeMemory()
//package com.java2s; //License from project: Open Source License public class Main { /**/* ww w .j a v a2 s . c o m*/ * Returns the free amount of memory (in MB) belonging to JVM. * * @return free memory */ public static int getFreeMemory() { return Math.round((float) (Runtime.getRuntime().freeMemory() / 1048576L)); } }