List of utility methods to do Memory Usage
long | getMemoryUsage() get Memory Usage Runtime runtime = Runtime.getRuntime(); long memoryInUse = runtime.totalMemory(); return memoryInUse; |
double | getMemoryUsage() get Memory Usage long usedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); return (double) usedMemory / (double) MEGABYTE_SIZE; |
String | getMemoryUsageSimpleHr() get Memory Usage Simple Hr return getHumanReadableByteCount(getMemoryUsed()) + " / " + getHumanReadableByteCount(getMemoryMax()); |
String | getMemoryUsageUnix() get Memory Usage Unix return "Not supported yet."; |
String | getMemoryUtiliztaion() get Memory Utiliztaion Runtime runtime = Runtime.getRuntime(); return "heap=" + df.format(runtime.totalMemory()) + " max=" + df.format(runtime.maxMemory()) + " used=" + df.format(runtime.totalMemory() - runtime.freeMemory()) + " free=" + df.format(runtime.freeMemory()); |
String | getMemUsage() get Mem Usage if (mbean == null) { mbean = ManagementFactory.getMemoryMXBean(); long used = mbean.getHeapMemoryUsage().getUsed(); long max = mbean.getHeapMemoryUsage().getMax(); NumberFormat f = DecimalFormat.getInstance(); f.setMaximumFractionDigits(2); f.setMinimumFractionDigits(2); ... |
double | getPercentMemoryUsage() get Percent Memory Usage return ((double) getMemoryUsage() / (double) getMaxMemory() * 100); |
int | getStringMemoryUsage(String s) Calculates the memory used by a string's data (not including the String object itself). return s.length() * 2;
|
long | getUsageMemory() get Usage Memory return getAllocatedMemory() - getFreeMemory();
|
String | memoryUsage() memory Usage Runtime r = Runtime.getRuntime(); long used = r.totalMemory() - r.freeMemory(); return "usedHeap=" + (used / 1000000) + "MB, percent=" + (100.0 * used / r.maxMemory()); |