Here you can find the source of getMemoryUtilizationPercent()
-Xmx
parameter)
0.0
and 1.0
.
public static float getMemoryUtilizationPercent()
//package com.java2s; //License from project: Open Source License public class Main { /**/* w w w . ja v a 2s.c om*/ * Get the amount of memory used by the current JVM as a percentage of the maximum amount of * memory it is allowed to use (via the <code>-Xmx</code> parameter) * * @return Memory utilization as a number between <code>0.0</code> and <code>1.0</code>. */ public static float getMemoryUtilizationPercent() { final Runtime rt = Runtime.getRuntime(); final float usedMemory = rt.totalMemory() - rt.freeMemory(); return usedMemory / rt.maxMemory(); } }