I've a Tomcat 6 installation in Ubuntu 10.04 and wanting to increase Java Heap space, I went to /etc/default/tomcat6 and uncommented and changed the following line:

JAVA_OPTS="-Djava.awt.headless=true -Xmx1024m"

However, when I went to the Tomcat Manager Status page, I read:

Free memory: 125.29 MB Total memory: 382.43 MB Max memory: 510.43 MB

So I went to check my /etc/init.d/tomcat6 script and added echo $TOMCAT_SH, just before start-stop-daemon --start, to check that the variable actually went through, and I got:

# /etc/init.d/tomcat6 start
* Starting Tomcat servlet engine tomcat6
'set -a; JAVA_HOME="/usr/lib/jvm/java-6-openjdk"; source "/etc/default/tomcat6"; CATALINA_HOME="/usr/share/tomcat6"; CATALINA_BASE="/var/lib/tomcat6"; JAVA_OPTS="-Djava.awt.headless=true -Xmx1024m -XX:+UseConcMarkSweepGC -Djava.net.preferIPv4Stack=true"; CATALINA_PID="/var/run/tomcat6.pid"; CATALINA_TMPDIR="/tmp/tomcat6-tmp"; LANG="en_GB"; JSSE_HOME="/usr/lib/jvm/java-6-openjdk/jre/"; cd "/var/lib/tomcat6"; "/usr/share/tomcat6/bin/catalina.sh" start'

Which looks OK, so I was wondering why Tomcat manager says I've only 510Mb of max memory.

How can I make sure that the memory setting has been applied?

  • Pardon the stupid question, but does your system indeed have more than 512MB of RAM? – SirCharlo Aug 21 '12 at 13:50
  • yes it does, it has 2Gb – stivlo Aug 21 '12 at 14:16

I am setting Java Options in my .profile file (right under /home/yourUserName/) globally.

All Java Processes will start with this params as long as you start them as your current user (not sudo)

just add

## set Java Options for the JVM
export _JAVA_OPTIONS="-Xmx1024m -Xms512m -XX:MaxPermSize=256m"

to the end of the .profile file,

Another possibility: Put the export at the beginning of a tomcat start script. should work also.


## set Java Options for the JVM
export _JAVA_OPTIONS="-Xmx1024m -Xms512m -XX:MaxPermSize=256m"

##start Tomcat
/etc/init.d/tomcat6 start

what we are using commonly is put the JAVA_OPTS and CATALINA_OPTS into the /etc/bash.bashrc file at the end. Then every user has access to the OPTS also the tomcat user.

To monitor if your changes are applied you could use the 'ps -AfH | grep tomcat' command, which will display all tomcat processes including their start params.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.