Wednesday, October 8, 2008

Preventing Tomcat's java.lang.OutOfMemoryError : PermGen space

This error is caused by the JVM's Permanent Generation memory space not being enough. the PermGen space is used by the JVM to load classes and rapid loading and unloading seems to cause this error.

The only way that I found to fix this is to enlarge the PermGen memory space by adding these parameters to the JVM during the startup of the application:

-XX:MaxPermSize=256M
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
-XX:+UseConcMarkSweepGC

and of course not to forget the normal max memory heap size override

-Xms256m
-Xmx1024m

Haha. 1st accomplshment in the new company! Now we can repackage the whole app to be deployed in a single server instance.

No comments: