Getting the Size of the Java Memory Heap
public class Main { public static void main(String[] argv) throws Exception { long heapSize = Runtime.getRuntime().totalMemory(); long heapMaxSize = Runtime.getRuntime().maxMemory(); long heapFreeSize = Runtime.getRuntime().freeMemory(); } }