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

longmemoryUsed()
memory Used
Runtime rt = Runtime.getRuntime();
return rt.totalMemory() - rt.freeMemory();
longmemoryUsed()
Returns the amount of memory on the heap that is currently being used by the JVM.
Runtime rt = Runtime.getRuntime();
return rt.totalMemory() - rt.freeMemory();
longmemoryUsedInMB()
Returns the amount of memory currently used by the JVM, in megabytes.
return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / MEGA;
StringstringMemoryUsedInMB()
Returns the amount of memory currently used by the JVM, in megabytes, as a string.
String ret = String.format("%,d MB", memoryUsedInMB());
return ret;
longusedMemory()
used Memory
return S_RUNTIME.totalMemory() - S_RUNTIME.freeMemory();
longusedMemory()
used Memory
return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
longusedMemory()
Returns the amount of memory currently used by the Java Virtual Machine.
return allocatedMemory() - freeAllocatedMemory();
longusedMemory()
Return the total memory currently in use.
return runtime.totalMemory() - runtime.freeMemory();
longusedMemory()
used Memory
return RUNTIME.totalMemory() - RUNTIME.freeMemory();
doubleusedMemory()
Returns used memory in MB
Runtime runtime = Runtime.getRuntime();
return usedMemory(runtime);