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