开发者

Tomcat - How to limit the maximum memory Tomcat will use

开发者 https://www.devze.com 2022-12-28 04:13 出处:网络
I am running Tomcat on a small VPS (256MB/512MB) and I want to explicitly limit the amount of memory Tomcat uses.

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
-Xms开发者_JS百科128m

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

Thanks in advance,

Gav


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.


Set JAVA_OPTS in your init script,

 export JAVA_OPTS="-Djava.awt.headless=true -server -Xms48m -Xmx1024M -XX:MaxPermSize=512m"


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

JAVA_OPTS="-Xms128m -Xmx256m"

0

精彩评论

暂无评论...
验证码 换一张
取 消