Here you can find the source of freeMemory()
public static long freeMemory()
//package com.java2s; public class Main { static Runtime runtime = Runtime.getRuntime(); public static long freeMemory() { return runtime.freeMemory(); }/*w w w . j a v a 2s. c o m*/ }