package de.atbits.cms.util; public class DebugHelper { // public static final boolean DEBUG = true; public static final boolean DEBUG = false; public static final boolean DEBUG_MEM = true; /** * trace memory informations * * @SuppressWarnings("all") */ public static void traceMemory(String msg) { if (false == DEBUG_MEM) { return; } int mb = 1024 * 1024; // Getting the runtime reference from system Runtime runtime = Runtime.getRuntime(); System.out.println("##### Heap statistics [MB] " + msg + "#####"); // Print used memory System.out.println("Used Memory:" + (runtime.totalMemory() - runtime.freeMemory()) / mb); // Print free memory System.out.println("Free Memory:" + runtime.freeMemory() / mb); // Print total available memory System.out.println("Total Memory:" + runtime.totalMemory() / mb); // Print Maximum available memory System.out.println("Max Memory:" + runtime.maxMemory() / mb); } /** * trace memory informations */ public static void traceMemory() { traceMemory(""); } }