Java Utililty Methods Memory Used

List of utility methods to do Memory Used

Description

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

Method

longusedMemory(Runtime runtime)
used Memory
return runtime.totalMemory() - runtime.freeMemory();
StringusedMemoryAsString()
used Memory As String
long avaiableMemory = usedMemory();
double d = avaiableMemory / 1048576;
return d + "MB";
intusedMemorym()
used Memorym
return (int) Math.floor((usedMemoryb() / megabytes));
doubleusedMemoryMB()
Get used memory in megabytes
return megaBytes(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
doubleusedMemoryPercents()
Returns percents of used memory.
Runtime runtime = Runtime.getRuntime();
long totalMemory = runtime.totalMemory();
return (double) (totalMemory - runtime.freeMemory()) / totalMemory * 100.0;
doubleusedMemoryRatio()
used Memory Ratio
return (double) usedMemory() / (double) maxMemory();
voiduseMemoryLimitOver()
use Memory Limit Over
memoryLimitOver = true;