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