2

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:

JVM
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'
...done.

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?

stivlo
  • 509
  • 1
  • 7
  • 13

2 Answers2

3

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.

jpee
  • 131
2

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.

i.e.

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

##start Tomcat
/etc/init.d/tomcat6 start
mondjunge
  • 3,336