How to get the min and max heap size settings of a VM from within a Java program?
You just need to use the Runtime object with Runtime.getRuntime() and then use methods like totalMemory() and freeMemory().