Tomcat - How to limit the maximum memory Tomcat wi

2020-02-24 12:43发布

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

3条回答
别忘想泡老子
2楼-- · 2020-02-24 13:07

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

JAVA_OPTS="-Xms128m -Xmx256m"

查看更多
Animai°情兽
3楼-- · 2020-02-24 13:09

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.

查看更多
女痞
4楼-- · 2020-02-24 13:23

Set JAVA_OPTS in your init script,

 export JAVA_OPTS="-Djava.awt.headless=true -server -Xms48m -Xmx1024M -XX:MaxPermSize=512m"
查看更多
登录 后发表回答