Here you can find the source of availableMemory()
public static long availableMemory()
//package com.java2s; //License from project: Open Source License public class Main { /** A static reference to {@link Runtime#getRuntime()}. */ public final static Runtime RUNTIME = Runtime.getRuntime(); /**/*from w ww . ja v a 2 s. c o m*/ * Returns the amount of available memory (free memory plus never allocated memory). * * @return the amount of available memory, in bytes. */ public static long availableMemory() { return RUNTIME.freeMemory() + RUNTIME.maxMemory() - RUNTIME.totalMemory(); } }