Sunday, June 16, 2013

Tomcat throwing Java.Lang.OutOfMemoryError: PermGen Space

Your Tomcat might have thrown such kind of exception while running : 


java.lang.OutOfMemoryError: PermGen space
Java heap is structured into regions called generations. The permanent generation is the area of the heap where class and method objects are stored. 
If an application loads a very large number of classes, then the permanent generation can get out of space.In that case , we  might need  increase the perm gen size in Tomcat using the files catalina.bat or catalina.sh .

Assign the following values to JAVA_OPTS and add this in catalina.bat or catalina.sh file.


JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1536m 
-Xmx1536m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m 
-XX:MaxPermSize=256m -XX:+DisableExplicitGC"
Snippet from catalina.sh file