Here you can find the source of availableMemoryPercent()
public static float availableMemoryPercent()
//package com.java2s; public class Main { /**/*from www .j av a 2 s .com*/ * Returns the amount of available memory in percents. */ public static float availableMemoryPercent() { return availableMemory() * 100.0f / Runtime.getRuntime().maxMemory(); } /** * 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()); } }