Get amount of free memory within the heap in bytes.
public class Main { public static void main(String[] argv) { long heapFreeSize = Runtime.getRuntime().freeMemory(); System.out.println(heapFreeSize); } }