Tomcat heap space settings seems not applied


Solution 1

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

Solution 2

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.

Author by


Updated on June 30, 2022


  • stivlo
    stivlo less than a minute

    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"; CATALINA_PID="/var/run/"; 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/" 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?

    • SirCharlo
      SirCharlo almost 10 years
      Pardon the stupid question, but does your system indeed have more than 512MB of RAM?
    • stivlo
      stivlo almost 10 years
      yes it does, it has 2Gb