Here you can find the source of availableMemory()
public static long availableMemory()
//package com.java2s; public class Main { /**/*from w ww . ja v a2 s .co m*/ * Returns the amount of available memory (free memory plus never allocated memory). */ public static long availableMemory() { return Runtime.getRuntime().freeMemory() + (Runtime.getRuntime().maxMemory() - Runtime.getRuntime().totalMemory()); } }