Here you can find the source of getTotalFreeMemory()
public static long getTotalFreeMemory()
//package com.java2s; //License from project: Open Source License public class Main { public static long getTotalFreeMemory() { return getFreeMemory() + (getMaxMemory() - getAllocatedMemory()); }//from www . j a va 2s.c o m public static long getFreeMemory() { return Runtime.getRuntime().freeMemory(); } public static long getMaxMemory() { return Runtime.getRuntime().maxMemory(); } public static long getAllocatedMemory() { return Runtime.getRuntime().totalMemory(); } }