Setting JMX attribute on VM as command line parameter
I've done some searching, but can't seem to find a way开发者_StackOverflow社区 to do this.
We'd like to proactively monitor our permgen space via JMX. It seems the best way to do this is through the UsageThreshold attribute on the "PS Perm Gen" MemoryPool. By default, this is set to 0. Is there a way to specify this, or any JMX attribute, as a -D parameter to VM so this can be set automatically at startup? Or is there another mechanism to load JMX attributes automatically?
Thanks.
Looks like you can set this programmatically - take a look at MemoryPoolMXBean and the section on "Usage Thresholds".
If you have some code to set this value programmatically then it would be trivial to have the code read the value to be set from a properties file or system property or whatever else.
精彩评论