By adding the following line to catalina.sh, 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
You must not use the symbol =. Simply use the following:
export CATALINA_OPTS="-Xms512M -Xmx1024M"
Answered by Joachim Sauer
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/setenv.sh
Answered by MeJ
You may not require export; simply add the following line to catalina.sh:
Answered by Phat H. VU
setenv.sh 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, catalina.sh changes. With any version of Tomcat, though, you may keep your setenv.sh 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 setenv.sh has changed over time. If you use catalina.sh, you’ll constantly see not only your changes, but also the changes that arrived with each later Tomcat version.
Answered by mentallurg
Navigate to the “Tomcat Directory”/bin folder.
Create setenv.sh if you’re using Linux, otherwise If you’re using Windows, make a setenv.bat file.
setenv.* file content:
export CATALINA_OPTS="$CATALINA_OPTS -Xms512m" export CATALINA_OPTS="$CATALINA_OPTS -Xmx8192m" 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 https://stackoverflow.com/questions/6897476/tomcat-7-how-to-set-initial-heap-size-correctly