Here you can find the source of getAvailableMemorySize()
public static long getAvailableMemorySize()
//package com.java2s; public class Main { /**/*from w ww . ja va 2 s .c om*/ * * Get available memory size * * @return long */ public static long getAvailableMemorySize() { long maxMemorySize = 512 * 1024 * 1024; if (Runtime.getRuntime().maxMemory() > maxMemorySize) { maxMemorySize = Runtime.getRuntime().maxMemory(); } long freeMemorySize = Runtime.getRuntime().freeMemory(); long totalMemorySize = Runtime.getRuntime().totalMemory(); long usedMemorySize = totalMemorySize - freeMemorySize; return maxMemorySize - usedMemorySize; } }