Java Utililty Methods Memory Available

List of utility methods to do Memory Available

Description

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

Method

longavailableMemory()
Returns the amount of available memory (free memory plus never allocated memory).
return RUNTIME.freeMemory() + RUNTIME.maxMemory() - RUNTIME.totalMemory();
longavailableMemory()
Determine the amount of available memory.
Runtime rt = Runtime.getRuntime();
return rt.maxMemory() - rt.totalMemory() + rt.freeMemory();
longavailableMemory()
Returns the amount of available memory (free memory plus never allocated memory).
return Runtime.getRuntime().freeMemory()
        + (Runtime.getRuntime().maxMemory() - Runtime.getRuntime().totalMemory());
floatavailableMemoryPercent()
Returns the amount of available memory in percents.
return availableMemory() * 100.0f / Runtime.getRuntime().maxMemory();
longgetAvailableMemory()
Gets the available memory.
Runtime runtime = Runtime.getRuntime();
int max = (int) (runtime.maxMemory() / 1024 / 1024);
int total = (int) (runtime.totalMemory() / 1024 / 1024);
int free = (int) (runtime.freeMemory() / 1024 / 1024);
free = free + max - total;
int used = max - free;
return free;
longgetAvailableMemory()
get Available Memory
Runtime runtime = Runtime.getRuntime();
long maxMemory = runtime.maxMemory();
long allocatedMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();
return freeMemory + (maxMemory - allocatedMemory);
longgetAvailableMemory()
get Available Memory
long freeMemory = Runtime.getRuntime().freeMemory();
return getMaximumMemory() - freeMemory;
longgetAvailableMemory()
TODO TEST!!
Runtime rt = Runtime.getRuntime();
long maxMem = rt.maxMemory();
long freeMem = rt.freeMemory();
long totalMem = rt.totalMemory();
long used = totalMem - freeMem;
long available = maxMem - used;
return available;
doublegetAvailableMemoryFraction()
get Available Memory Fraction
Runtime runtime = Runtime.getRuntime();
long maxMemory = runtime.maxMemory();
long allocatedMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();
return (double) ((freeMemory + (maxMemory - allocatedMemory))) / maxMemory;
longgetAvailableMemorySize()
Get available memory size
long maxMemorySize = 512 * 1024 * 1024;
if (Runtime.getRuntime().maxMemory() > maxMemorySize) {
    maxMemorySize = Runtime.getRuntime().maxMemory();
long freeMemorySize = Runtime.getRuntime().freeMemory();
long totalMemorySize = Runtime.getRuntime().totalMemory();
long usedMemorySize = totalMemorySize - freeMemorySize;
return maxMemorySize - usedMemorySize;
...