Contributed by spvijay on 7 Jun 2009
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.
Some interesting discussions and articles relates to tomcat performance can be found at
Visit us at Neevtech.com to know more about our offerings.
© 2015 Neevtech Blog | Neev Technologies