Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
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

2 Answers 2

up vote 2 down vote accepted

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
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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