Here you can find the source of freeMemory()
public static void freeMemory()
//package com.java2s; //License from project: Open Source License public class Main { public static void freeMemory() { try {/*from w w w.j a v a 2 s . c om*/ System.gc(); System.gc(); Thread.currentThread().sleep(250); System.runFinalization(); System.runFinalization(); Thread.currentThread().sleep(250); System.gc(); System.gc(); } catch (Exception e) { } } }