List of utility methods to do Memory Information
void | printMemory() print Memory int mb = 1024 * 1024; Runtime runtime = Runtime.getRuntime(); System.out.println("##### Heap utilization statistics [MB] #####"); System.out.println("Used Memory:" + (runtime.totalMemory() - runtime.freeMemory()) / mb); System.out.println("Free Memory:" + runtime.freeMemory() / mb); System.out.println("Total Memory:" + runtime.totalMemory() / mb); System.out.println("Max Memory:" + runtime.maxMemory() / mb); |
void | printMemory(String label) print Memory System.out.println(label); Runtime rt = Runtime.getRuntime(); System.out.println(" Total memory: " + rt.totalMemory()); System.out.println(" Free memory: " + rt.freeMemory()); System.out.println(" Max memory: " + rt.maxMemory()); |
void | printMemory(String str) print Memory long total = Runtime.getRuntime().totalMemory(); long free = Runtime.getRuntime().freeMemory(); long used = total - free; System.out.println("MEM " + str + " used: " + (used / 1024) + " KB delta: " + ((used - lastMemUsed) / 1024) + " KB"); lastMemUsed = used; |
void | printMemoryInfo() Print memory info Runtime currRuntime = Runtime.getRuntime(); int nFreeMemory = (int) (currRuntime.freeMemory() / 1024 / 1024); int nTotalMemory = (int) (currRuntime.totalMemory() / 1024 / 1024); String message = nFreeMemory + "M/" + nTotalMemory + "M(free/total)"; System.out.println("memory:" + message); |
void | printMemoryInstruction(byte[] instruction) print Memory Instruction for (int i = 0; i < instruction.length; i++) { System.out.print( String.format("%8s", Integer.toBinaryString(instruction[i] & 0xff)).replace(' ', '0') + " "); if (i % 4 == 3) System.out.println(); |
void | showMemory() show Memory System.out.println("free: " + Runtime.getRuntime().freeMemory() / 1000000.0 + " MB"); System.out.println("max: " + Runtime.getRuntime().maxMemory() / 1000000.0 + " MB"); System.out.println("total: " + Runtime.getRuntime().totalMemory() / 1000000.0 + " MB"); System.out.println(); |
void | showMemoryInfo() show Memory Info final Runtime runtime = Runtime.getRuntime(); final long maxMemory = runtime.maxMemory(); final long allocatedMemory = runtime.totalMemory(); final long freeMemory = runtime.freeMemory(); System.out.println("------------------------------------------------------"); System.out.println("free memory: " + (freeMemory / 1024.0 / 1024.0) + " Mb"); System.out.println("allocated memory: " + (allocatedMemory / 1024.0 / 1024.0) + " Mb"); System.out.println("max memory: " + (maxMemory / 1024.0 / 1024.0) + " Mb"); ... |