How to set Java heap size in Tomcat

Posted: August 27, 2010 in Linux

Most of the time you may get ‘OutOfMemoryError’ when you run Tomcat application.  This is because your default tomcat heap size is small or it is not enough for your web applications.

To set the java heap size, follow the below steps:

– Stop Tomcat server

– run the following command

export CATALINA_OPTS=”-Xms256m -Xmx512m”

or

export JAVA_OPTS=”-Xms256m -Xmx512m”

– Start Tomcat

You can also use the above variables in your Tomcat startup scripts:

Check the file Tomcat-Home/bin/catalina.sh or catalina.bat , and then restart the Tomcat server

set CATALINA_OPTS=-Xms256m -Xmx512m (For Windows, no “” around the value)

export CATALINA_OPTS=-Xms256m -Xmx512m (For ksh/bash, “” around the value)

setenv CATALINA_OPTS=-Xms256m -Xmx512m (For tcsh/csh, “” around the value)


Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s