Java Utililty Methods Memory

List of utility methods to do Memory

Description

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

Method

booleanisDefaultMemoryCardDrive(String aRoot)
is Default Memory Card Drive
if (aRoot.equalsIgnoreCase(iDefaultMemoryCard)) {
    return true;
return false;
booleanisInMemoryDatabase(final String databasePath)
is In Memory Database
return MEMORY_STORE_LOCATION.equals(databasePath);
booleanisMemoryAccess(final String value)
Checks whether a string is a memory access identifier string.
return value.equals("[");
booleanisMemoryData(String metric)
is Memory Data
if (metric == null) {
    return false;
if (metric.indexOf("mem") > -1) {
    return true;
return false;
booleanisMemorySufficient()
is Memory Sufficient
final long maxMemory = ((Runtime.getRuntime().maxMemory() / 1024) / 1024);
final long freeMemory = ((Runtime.getRuntime().freeMemory() / 1024) / 1024);
if ((freeMemory) < ((1 * maxMemory) / 100)) {
    return false;
return true;
voidlogMemoryStats(String msg)
Log statistics on memory to stderr.
Runtime rt = Runtime.getRuntime();
System.err.println(
        msg + ": total=" + (rt.totalMemory() / 1024) + "KB, free=" + (rt.freeMemory() / 1024) + "KB");
longmakeVmMemoryDivisibleBy4(long memory)
make Vm Memory Divisible By
if ((memory % 4) == 0) {
    return memory;
} else {
    long temp = memory / 4;
    return temp * 4;
voidmeasureMemoryBefore()
measure Memory Before
measureMemory("Before");
Stringmemory()
memory
Runtime r = Runtime.getRuntime();
long max = r.maxMemory() / 1000;
return "memory (used/free/max): " + (max - freeMemory()) / 1000 + "/" + freeMemory() / 1000 + "/"
        + r.maxMemory() / 1000000;
Stringmemory()
memory
String str = "";
str += "memory : "
        + ((double) Runtime.getRuntime().freeMemory() / (double) Runtime.getRuntime().totalMemory()) * 100
        + "% free<br>";
str += "memory total : " + Runtime.getRuntime().totalMemory() + "<br>";
str += "memory free : " + Runtime.getRuntime().freeMemory() + "<br>";
return str;