Here you can find the source of isFreeMemoryAvailable()
public static boolean isFreeMemoryAvailable()
//package com.java2s; //License from project: Apache License public class Main { public static boolean isFreeMemoryAvailable() { Runtime runtime = Runtime.getRuntime(); long maxMemory = runtime.maxMemory(); long totalFree = runtime.freeMemory() + maxMemory - runtime.totalMemory(); return totalFree > maxMemory * 0.2; }// w w w . j av a 2 s . co m }