Solution for tomcat java.lang.OutOfMemoryError: PermGen space

by rajesh 2012-10-16 17:37:21

Solution for java.lang.OutOfMemoryError: PermGen space

If your server gives a bad gateway error and you can find the below lines in the tomcat error log "java.lang.OutOfMemoryError: PermGen space", try the below solution

Add the flags along with -Xms and -Xmx values
-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled


Example: if in cause your starttomcat is in /usr/sbin/ then edit it and add the flags -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

The final part of the script may look like
./jsvc
-user tomcat
-Xms1024M -Xmx2048M -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -cp ./bootstrap.jar
-Djava.endorsed.dirs=../common/endorsed
-outfile ../logs/catalina.out
-errfile ../logs/catalina.err
-verbose
417
like
0
dislike
0
mail
flag

You must LOGIN to add comments
Nikita

Unfortunately this could be of no use. I have written a blog post some time ago explaining why this change is not sufficient: http://plumbr.eu/blog/busting-permgen-myths