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 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 to know more about our offerings.


  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: