Coder Perfect

Tomcat 7: How to set initial heap size correctly?


By adding the following line to, I was able to adjust the initial heap size of a Tomcat 7 (CentOS, java -version: 1.6.0 25-b06) instance:

export CATALINA_OPTS="-Xms=512M -Xmx=1024M"

Tomcat fails to start, and the following message is logged to catalina.out:

Invalid initial heap size: -Xms=512m
Could not create the Java virtual machine.

What’s the problem with these choices?

Asked by GLA

Solution #1

You must not use the symbol =. Simply use the following:

export CATALINA_OPTS="-Xms512M -Xmx1024M"

Answered by Joachim Sauer

Solution #2

To correctly increase the java heap size for Tomcat7 (linux distributions), run the following command:

echo 'export CATALINA_OPTS="-Xms512M -Xmx1024M"' > /usr/share/tomcat7/bin/

Answered by MeJ

Solution #3

You may not require export; simply add the following line to

CATALINA_OPTS="-Xms512M -Xmx1024M"

Answered by Phat H. VU

Solution #4 is preferable since it allows you to simply transfer settings from one machine to another or from one Tomcat version to another. From one Tomcat version to the next, changes. With any version of Tomcat, though, you may keep your unmodified.

Another advantage is that adding it to your backup or versioning system makes it easy to follow the history of your modifications. Only your own changes will be visible if you look at how has changed over time. If you use, you’ll constantly see not only your changes, but also the changes that arrived with each later Tomcat version.

Answered by mentallurg

Solution #5

Navigate to the “Tomcat Directory”/bin folder.

Create if you’re using Linux, otherwise If you’re using Windows, make a setenv.bat file.

setenv.* file content:

export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxPermSize=256m"

Restart Tomcat with the modified parameters.

The complete explanation and facts may be found here.

Answered by Musa

Post is based on