Here you can find the source of getAvailableMemory()
public static long getAvailableMemory()
//package com.java2s; //License from project: Open Source License public class Main { public static long getAvailableMemory() { Runtime runtime = Runtime.getRuntime(); long maxMemory = runtime.maxMemory(); long allocatedMemory = runtime.totalMemory(); long freeMemory = runtime.freeMemory(); return freeMemory + (maxMemory - allocatedMemory); }//from w ww . ja v a2 s. c o m }