Please enter name
please enter valid email
please enter comment
Please enter correct code

Apache Tomcat OutOfMemory Exceptions - HeapSpace, PermGen Space

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.
•    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

Visit us at Neevtech.com to know more about our offerings.

2 Comments

  1. I just signed up to your blogs rss feed. Will you post more on this subject?
    My blog is Detox diet plan.

  2. You could certainly see your skills within the paintings you write. The sector hopes for more passionate writers such as you who are not afraid to mention how they believe. Always go after your heart.

Leave a Comment

Security Code: