Get current size of heap in bytes
public class Main { public static void main(String[] argv) { long heapSize = Runtime.getRuntime().totalMemory(); System.out.println(heapSize); } }