List of utility methods to do Memory Usage
String | memoryUsage() Calculates the memory usage according to Runtime. final Runtime runtime = Runtime.getRuntime(); runtime.gc(); final long max = runtime.maxMemory(); final long total = runtime.totalMemory(); final long free = runtime.freeMemory(); final long used = total - free; return String.format("%d\t%d\t%d\t%d", max, total, free, used); |
String | memoryUsage() memory Usage final StringBuffer buf = new StringBuffer(80); buf.append("(used:").append(usedMemorym()); buf.append("M/").append(freeMemorym()); buf.append("M [").append(totalMemorym()); buf.append("M,").append(maxMemorym()); buf.append("M ])"); return buf.toString(); |
void | printMemoryUsage() print Memory Usage System.out.println(getMemoryUsageHr()); |
String | reportMemoryUsage() report Memory Usage Runtime r = Runtime.getRuntime(); return String.valueOf((r.totalMemory() - r.freeMemory()) / (1024 * 1024)) + " MB"; |
void | showMemoryUsage() show Memory Usage Runtime runtime = Runtime.getRuntime(); long maxMemory = runtime.maxMemory(); long allocatedMemory = runtime.totalMemory(); long freeMemory = runtime.freeMemory(); System.out.println("-- MEMORY USAGE -----------------"); System.out.println("-- free memory: " + freeMemory / 1024); System.out.println("-- allocated memory: " + allocatedMemory / 1024); System.out.println("-- max memory: " + maxMemory / 1024); ... |