views:

114

answers:

3

Hi Guys,

I am running Tomcat on a small VPS (256MB/512MB) and I want to explicitly limit the amount of memory Tomcat uses.

I understand that I can configure this somehow by passing in the java maximum heap and initial heap size arguments;

-Xmx256m
-Xms128m

But I can't find where to put this in the configuration of Tomcat 6 on Ubuntu.

Thanks in advance,

Gav

+1  A: 

You can add this to the JAVA_OPTS variable in the bin/catalina.sh startup script.

JAVA_OPTS="-Xms128m -Xmx256m"

danben
+1  A: 

Set JAVA_OPTS in your init script,

 export JAVA_OPTS="-Djava.awt.headless=true -server -Xms48m -Xmx1024M -XX:MaxPermSize=512m 
stacker
What does `-Djava.awt.headless=true` do?
danben
Prevents exceptions is you have some older applications rendering graphics http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/
stacker
And -server optimises for running on a server?
gav
A: 

On Ubuntu, the correct way to customize Tomcat variables is by editing the file

/etc/default/tomcat5.5

(or /etc/default/tomcat6 if you have a newer version running)

Inside that file, set the JAVA_OPTS variable as described in the other replies here, for example

JAVA_OPTS="-Xmx512m"

to set a maximum memory of 512 MB.

Photodeus