Came across an interesting problem and noticed that we usually treat all “tomcat OutOfMemory” issues by just adding the java xms & xmx options. This may not be right solution as this just increases the JVM heap space and hence would take care of the exception which is related heap space i.e. Exception in thread “main” java.lang.OutOfMemoryError: Java heap space.
For the exception related to permGen i.e. java.lang.OutOfMemoryError: PermGen space, need to add one more option in JAVA_OPTS called MaxPermSize.
After adding all these options, here is what the entry for JAVA_OPTS looks like in the catalina.sh file.
export JAVA_OPTS=”-server -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m $JAVA_OPTS”.
Each of these otions are explained below.
• Server - Run the tomcat in server mode. (the default is developer mode)
• Xms - Minimum java heap space
• Xmx - Maximum java heap space. While running on dedicated servers for production instances, keep both these options the same to ensure better utilization of available memory.
• PermSize - The initial permSize. (default is 64MB)
• Max PermSize - The maxPermSize. (even here, it may be a good idea to keep the intial and the max value the same).
More information relate to OutOfMemory exceptions can can be found in the following articles.
• http://www.freshblurbs.com/explaining-java-lang-outofmemoryerror-permgen-space
• http://raibledesigns.com/rd/entry/how_do_you_determine_a
Some interesting discussions and articles relates to tomcat performance can be found at
• http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html#Production%20Configuration
• http://wiki.apache.org/tomcat/FAQ/Performance_and_Monitoring
• http://kinetic.more.net/web/javaserver/resources/wpapers/performance.shtml