Here you can find the source of measureMemoryBefore()
public static void measureMemoryBefore()
//package com.java2s; public class Main { public static final int MB = 1024 * 1024; public static void measureMemoryBefore() { measureMemory("Before"); }//from ww w.j av a 2 s .c om public static void measureMemory(String phase) { long totalMemory = Runtime.getRuntime().totalMemory() / MB; long freeMemory = Runtime.getRuntime().freeMemory() / MB; long maxMemory = Runtime.getRuntime().maxMemory() / MB; //J- System.out.printf( "[%s]: total_memory=[%,d] (MB) \t free_memory=[%,d] (MB) \t max_memory=[%,d] (MB) \t used_memory=[%,d] (MB) \n", phase, totalMemory, freeMemory, maxMemory, totalMemory - freeMemory); //J+ } }