java Tomcat 6 堆大小 - 这是正确的吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2144037/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Tomcat 6 Heap Size - Is this correct?
提问by user353829
I am running multiple tomcats on a Red Hat box and I would like to configure separate heap size for each of them (some instances use more memory).
我在 Red Hat 机器上运行多个 tomcat,我想为每个配置单独的堆大小(某些实例使用更多内存)。
Can I set the heap size min/max bt entering the following into the catalina.sh file:
我可以设置堆大小最小/最大 bt 将以下内容输入 catalina.sh 文件:
CATALINA_OPTS="-Xms64m -Xmx256m"
CATALINA_OPTS="-Xms64m -Xmx256m"
Do I need add 'export'? i.e. export CATALINA_OPTS="-Xms64m -Xmx256m"
我需要添加“导出”吗?即出口 CATALINA_OPTS="-Xms64m -Xmx256m"
回答by matt b
Best practice is to put the setting of environment variables in a file named setenv.sh/.batin the bin folder.
最佳做法是将环境变量的设置放在bin 文件夹中名为setenv.sh/.bat的文件中。
The catalina.shscript has logic to call into this script, if it exists.
该catalina.sh脚本具有调用此脚本的逻辑(如果存在)。
The reason why this is recommended is because it makes setting of environment variables needed for your installation portable: you can easily copy setenv.shto other Tomcat installations, you can upgrade Tomcat to a newer version (which might overwrite catalina.sh) but still have your existing setenv.sh.
推荐这样做的原因是因为它使安装所需的环境变量设置可移植:您可以轻松复制setenv.sh到其他 Tomcat 安装,您可以将 Tomcat 升级到更新版本(可能会覆盖catalina.sh)但仍然保留现有的setenv.sh.
An example on how to set the heap size inside setenv.sh:
关于如何在里面设置堆大小的示例setenv.sh:
export JAVA_OPTS='-Xmx784M`
回答by Sean Owen
If you add this to anything in the Tomcat installation, it will affect all instances run on that machine.
如果您将此添加到 Tomcat 安装中的任何内容,它将影响该机器上运行的所有实例。
I think you want to set JAVA_OPTS separately, in separate scripts, which each then invoke Tomcat's startup script. The scripts can set different heap sizes. Yes, you need to export.
我认为您想在单独的脚本中单独设置 JAVA_OPTS,然后每个脚本都会调用 Tomcat 的启动脚本。脚本可以设置不同的堆大小。是的,您需要导出。

