The list of methods to do Memory Information are organized into topic(s).
String
getAviableMemoryAsString() get Aviable Memory As String
long avaiableMemory = getAvaiableMemory();
double d = avaiableMemory / 1048576;
return (int) d + "MB";
char
getDenotationOfJVMMemorySettings(String stringMapJavaOpts) get Denotation Of JVM Memory Settings
int index = -1;
if (stringMapJavaOpts.lastIndexOf('k') != -1) {
return 'k';
} else if (stringMapJavaOpts.lastIndexOf('K') != -1) {
return 'K';
} else if ((index = stringMapJavaOpts.lastIndexOf('m')) != -1 && index != 2) {
return 'm';
} else if ((index = stringMapJavaOpts.lastIndexOf('M')) != -1) {
...
long
getJavaMemorySize(String string) get Java Memory Size
String suffix = string.substring(string.length() - 1);
if (!suffix.matches(DIGITS_PATTERN)) {
long value = Long.parseLong(string.substring(0, string.length() - 1));
if (suffix.equalsIgnoreCase("k")) {
value *= K;
} else if (suffix.equalsIgnoreCase("m")) {
value *= M;
} else if (suffix.equalsIgnoreCase("g")) {
...
long
getJVMMemoryMB() get JVM Memory MB
return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / mb;
String
getMemory() get Memory
return tidyFileSize(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) + " / "
+ tidyFileSize(Runtime.getRuntime().totalMemory()) + " / "
+ tidyFileSize(Runtime.getRuntime().maxMemory());
long
getMemory() get Memory
long used = 0;
for (int i = 0; i < 10; i++) {
System.gc();
long total = Runtime.getRuntime().totalMemory();
long free = Runtime.getRuntime().freeMemory();
used = total - free;
if (used < MAX_MEMORY)
return used;
...
long
getMemory(String memory) get Memory
switch (memory.charAt(memory.length() - 1)) {
case 'k':
case 'K':
return Long.parseLong(memory.substring(0, memory.length() - 1)) * 1000L;
case 'm':
case 'M':
return Long.parseLong(memory.substring(0, memory.length() - 1)) * 1000000L;
case 'g':
...
long
getMemoryConsumedSincePreviousCall() Returns amount of memory consumed since last call to getFreeMemory() (or this method)
long currentConsumption = runtime.freeMemory();
long consumed = currentConsumption - lastMemoryReading;
lastMemoryReading = currentConsumption;
return consumed;