Wednesday, May 14, 2008

If Tomcat is Running out of Memory...

If your Tomcat is running out of memory, take a look at the following issue posted by Atlassian. It affects basically all Tomcat versions including Tomcat 6.

The fix is to set the following JVM parameter:

-Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true

And, just for completeness - if you need to specifiy JVM parameters for Tomcat, create a file called setenv.sh in your Tomcat's bin directory.

e.g.

#!/bin/sh

CATALINA_OPTS=" \
-Xms512m -Xmx512m \
-XX:PermSize=128m -XX:MaxPermSize=256m \
-server \
-Djava.awt.headless=true \
-Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true"

export CATALINA_OPTS

Tomcat will pick up the file automatically when it starts up. Regarding Permspace issues, there was a good discussion about it over at Matt Raible's Blog.

2 comments:

ArrayList said...

PermGen memory error in Tomcat may not be just because of in sufficient memory but also due to serious leak as explained in <a href="http://javarevisited.blogspot.sg/2012/01/tomcat-javalangoutofmemoryerror-permgen.html>PermGen memory leak in Tomcat</a>. As Tomcat use different classloader to load different web app.

ArrayList said...

PermGen memory error in Tomcat may not be just because of in sufficient memory but also due to serious leak as explained in <a href="http://javarevisited.blogspot.sg/2012/01/tomcat-javalangoutofmemoryerror-permgen.html>PermGen memory leak in Tomcat</a>. As Tomcat use different classloader to load different web app.