List of utility methods to do Memory Free
boolean | belowMemoryLimit(int percentFree) below Memory Limit long max = Runtime.getRuntime().maxMemory() / 1000; long free = freeMemory(); if ((double) free / max * 100 < percentFree) return true; return false; |
boolean | checkFreeMemory(long requiredMemory) Check if there is enough free memory. if (Runtime.getRuntime().freeMemory() >= requiredMemory) { return true; return false; |
String | formatMemorySize(Long afreeDiskSpace) format Memory Size freeDiskSpace = afreeDiskSpace; if (afreeDiskSpace < 1024) { return "Free Disk Space: " + afreeDiskSpace + "B"; } else if (afreeDiskSpace < 1048576) { return "Free Disk Space: " + afreeDiskSpace / 1024 + "KB"; } else if (afreeDiskSpace < 1073741824) { return "Free Disk Space: " + afreeDiskSpace / 1048576 + "MB"; } else { ... |
long | freeAllocatedMemory() Returns the amount of free memory in the Java Virtual Machine. return Runtime.getRuntime().freeMemory();
|
long | freeMemory() free Memory return Runtime.getRuntime().freeMemory();
|
void | freeMemory() Utility to free memory long total = Runtime.getRuntime().totalMemory(); for (int i = 0; i < 10; i++) { System.gc(); while (true) { System.gc(); long newtotal = Runtime.getRuntime().totalMemory(); if ((((double) (total - newtotal)) / (double) total) < 0.1) { ... |
void | freeMemory() free Memory try {
System.gc();
System.gc();
Thread.currentThread().sleep(250);
System.runFinalization();
System.runFinalization();
Thread.currentThread().sleep(250);
System.gc();
...
|
long | freeMemory() Wrapper around Runtime.getRuntime().freeMemory()
return Runtime.getRuntime().freeMemory();
|
long | freeMemory() free Memory return runtime.freeMemory();
|
int | freeMemorym() free Memorym return (int) Math.floor((freeMemoryb() / megabytes)); |