How can I view the MaxPermSize in JVM?

我怕爱的太早我们不能终老 提交于 2019-12-12 10:15:31

问题


I'm meeting the dreadful PermGen:Out of memory error when deploying a web-app on TomCat. I have tried many possible solutions, but they don't work out(sometimes it works, usually it doesn't). I wonder if my config in "BuildConfig.groovy" take effect:

grails.tomcat.jvmArgs = ["-Xmx1024m", "-XX:MaxPermSize=1024m"]

Does anyone know someway to view the MaxPermSize actually applied by the JVM?


回答1:


You can use JVisualVM in the JDK/bin directory to monitor everything about a java process.




回答2:


In direct answer to your question, java.lang.management.ManagementFactory has method to get information on all of the memory pools used by java, including the PermGen space and other non-heap memory pools:

List<MemoryPoolMXBean> memoryPoolMXBeans = java.lang.management.ManagementFactory.getMemoryPoolMXBeans();

for (MemoryPoolMXBean bean : memoryPoolMXBeans) {
    //Iterate over pools here
}



回答3:


There's a couple of utilities that come in the jsdk i believe - try jstat -gcpermcapacity. Another trick that can sometimes be helpful is ps -fwwwC java (assuming you are running this on a linux box)



来源:https://stackoverflow.com/questions/5176748/how-can-i-view-the-maxpermsize-in-jvm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!