Here you can find the source of freeMemoryPercents()
public static double freeMemoryPercents()
//package com.java2s; //License from project: Open Source License public class Main { /**//ww w . ja va 2 s.co m * Returns percents of free memory. */ public static double freeMemoryPercents() { Runtime runtime = Runtime.getRuntime(); return (double) runtime.freeMemory() / runtime.totalMemory() * 100.0; } /** * Returns amount of free memory in bytes. */ public static long freeMemory() { return Runtime.getRuntime().freeMemory(); } /** * Returns amount of total memory in bytes. */ public static long totalMemory() { return Runtime.getRuntime().totalMemory(); } }