I am trying to find out programatically the max permgen and max heap size with which a the JVM for my program has been invoked, not what is currently available to them.
Try something like this for max perm gen:
public static long getPermGenMax() {
for (MemoryPoolMXBean mx : ManagementFactory.getMemoryPoolMXBeans()) {
if ("Perm Gen".equals(mx.getName())) {
return mx.getUsage().getMax();
}
}
throw new RuntimeException("Perm gen not found");
}
For max heap, you can get this from Runtime, though you can also use the appropriate MemoryPoolMXBean.