Java jvm PermGen errors

I recently set up a Tomcat 6.x server for our Documentum web apps, which are java-based. Annoyingly, I was regularly getting error messages saying there was insufficient memory and “PermGen” space. I won’t go into great detail about this, but at a high level, a java virtual machine (jvm) has internal memory allocations that are periodically garbage-collected, i.e. no-longer-needed allocations are cleaned out and the space freed. There is a lot of debate about why and whose code is at fault, but the fact remains it doesn’t seem to work very well right now, particularly for PermGen space. Fortunately, after much gleaning and some experimentation, I found some startup parameters that seem to have resolved it for me. YMMV and all that, of course.

In Tomcat on Windows (yeah I know), go to Start > All Programs > Apache Tomcat 6.0 > Configure Tomcat > Java and put these in the Java Options textbox. For any other platform or java server, you probably already know where these go. :)  MaxPermSize may need tweaking depending on the java apps you are running. If you still get errors that indicate you are running out of PermGen, try increasing MaxPermSize, but there is a limit depending on your total memory allocation. I have mine set to 1024M max memory and Tomcat wouldn’t even start if I set MaxPermSize to large values like 512M. If you need that much PermGen you will need to allocate more total memory as well. MaxPermSize=128M seems to have been enough in my case. You’ll just have to experiment – or find a better blog post.

-XX:+UseConcMarkSweepGC
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
-XX:MaxPermSize=128M
Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s