Thursday, 20 August 2009

OutOfMemoryError: PermGen space in Tomcat 6. The Solution:

I'm blogging this as much for my own use as help for other's.

Every time I set up a new Tomcat server I forget these options! Once you find them keep them safe.

set JAVA_OPTS=-Xms256m -Xmx1024m -Xss96k -XX:MaxPermSize=512m -server -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

It's the CMSClassUnloadingEnabled that prevents the OOM error. The memory options depend on your hardware.

To set these options for the Sand Box Server in eclipse goto window -> preferences. In the left hand view select servers click on the tomcat server and add the above to the startup options. I'd post a screen shot but I'm using MyEclipse which is a bit niche for most developers.