问题
In order to decide if the jvm is likely to run into a permgen space shortage after the next redeplyoment I'd like to monitor the current permgen space usage before hand
something like:
set myPermGenThreshold = 0.51 (51%)
currentlyUsedPermGenSize = (...ask the jvm here... say it's 0.6)
if (currentlyUsedPermGenSize > myPermGenThreshold ) {
(...restart tomcat...)
}
else {
(...redeploy application...)
}
回答1:
The Memory MX Bean will give you all non-heap usage, of which the perm gen is a part. The size of the perm gen pool itself should be available using the Memory Pool MX Bean, but be aware that the names of the pools are implementation and GC-dependent.
Both of these JMX beans are available from the platform server, as usual, so they should be obtainable externally using a JMX client.
Edit - links updated to 1.7.
来源:https://stackoverflow.com/questions/12086703/howto-monitor-permgen-space-usage-before-redeploying-in-tomcat