1

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?

Community
  • 1
  • 1
Hoàng Long
  • 10,746
  • 20
  • 75
  • 124

3 Answers3

4

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
}
Dori
  • 915
  • 1
  • 12
  • 20
3

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

Phani
  • 5,319
  • 6
  • 35
  • 43
1

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)

jhodges
  • 3,065
  • 2
  • 17
  • 9
  • unfortunately I'm working on Windows at this time. How could I try your command? – Hoàng Long Mar 03 '11 at 07:14
  • You can also use jconsole to connect to your process and monitor the PermGen usage. This should be available on Windows as well. – jhodges May 24 '11 at 17:09