how to get the min and max heap size settings of a JVM from within a Java program
max heap size:
Runtime.getRuntime().maxMemory();
Some other calculations which you may find interesting:
Runtime runtime = Runtime.getRuntime();
long maxMemory = runtime.maxMemory();
long allocatedMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();
long totalFreeMemory = freeMemory + (maxMemory - allocatedMemory);
long usedMemory = maxMemory - totalFreeMemory;
You just need to use the Runtime object with Runtime.getRuntime() and then use methods like totalMemory() and freeMemory().