Possible Duplicate:
Read Java JVM startup parameters (eg -Xmx)
We have a desktop application where some old installations does not have the appropriate memory settings.
They experience out of perm gen space at "random" times and i need to alert the users which are running too low MaxPermSize but i can't figure out how to access this setting from the jvm.
This should give you a rough idea on how to do it
public class Main {
public static void main(final String[] args) {
final RuntimeMXBean memMXBean = ManagementFactory.getRuntimeMXBean();
final String prefix = "-XX:MaxPermSize=";
final List<String> jvmArgs = memMXBean.getInputArguments();
String maxPermSize = null;
for (final String jvmArg : jvmArgs) {
if (jvmArg.startsWith(prefix)) {
maxPermSize = jvmArg.substring(prefix.length());
break;
}
}
System.out.println("MaxPermSize is " + maxPermSize);
}
}