Java Utililty Methods Memory Free

List of utility methods to do Memory Free

Description

The list of methods to do Memory Free are organized into topic(s).

Method

doublefreeMemoryMB()
Get free memory in megabytes
return megaBytes(Runtime.getRuntime().freeMemory());
doublefreeMemoryPercents()
Returns percents of free memory.
Runtime runtime = Runtime.getRuntime();
return (double) runtime.freeMemory() / runtime.totalMemory() * 100.0;
voidfreeReserveMemory()
Free up the reserve memory.
reserveMemory = null;
longgetFreeJVMMemoryMB()
get Free JVM Memory MB
return Runtime.getRuntime().freeMemory() / mb;
longgetFreeLiveMemory()
get Free Live Memory
Runtime r = Runtime.getRuntime();
r.gc();
return r.freeMemory();
intgetFreeMemory()
Returns the free amount of memory (in MB) belonging to JVM.
return Math.round((float) (Runtime.getRuntime().freeMemory() / 1048576L));
longgetFreeMemory()
Gets the JVM free memory.
return getFreeMemory(false);
longgetFreeMemory()
get Free Memory
lastMemoryReading = runtime.freeMemory();
return lastMemoryReading;
longgetFreeMemory(boolean preRunGarbageCollector)
get Free Memory
Runtime rt = getRuntimeAndRunGC(preRunGarbageCollector);
return bytesToMegabytes(rt.freeMemory());
longgetFreeMemoryForAppInKB()
Gets the free memory in kilobytes is available for the application.
return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024;