tomcat内存简单调优

Posted 我是冰霜

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tomcat内存简单调优相关的知识,希望对你有一定的参考价值。

1.linux下调节tomcat初始内存大小

linux下tomcat的运行文件为catalina.sh,打开文件,在文件靠近顶部找到“ JAVA_OPTS ”字样,在它后面添加如下内容即可

#   JAVA_OPTS       (Optional) Java runtime options used when any command
#                   is executed.
#                   Include here and not in CATALINA_OPTS all options, that
#                   should be used by Tomcat and also by the stop process,
#                   the version command etc.
#                   Most options should go into CATALINA_OPTS.
#
JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms700m -Xmx1024m -XX:NewSize=512m -XX:MaxNewSize=1024m -XX:PermSize=512m -XX:MaxPermSize=512m"
#   JAVA_ENDORSED_DIRS (Optional) Lists of of colon separated directories
#                   containing some jars in order to allow replacement of APIs
#                   created outside of the JCP (i.e. DOM and SAX from W3C).
#                   It can also be used to update the XML parser implementation.
#                   Defaults to $CATALINA_HOME/endorsed.

2.windows下调节tomcat初始内存大小

windows下tomcat的运行文件为catalina.bat,打开文件,在文件中部找到“rem ----- Execute The Requested Command -----”字样 ,在它后面添加如下内容即可

set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%"

rem ----- Execute The Requested Command ---------------------------------------

set JAVA_OPTS=%JAVA_OPTS% -server -Xms2048m -Xmx2048m -Xmn512m -XX:PermSize=400m -XX:MaxPermSize=700m

echo Using CATALINA_BASE:   "%CATALINA_BASE%"
echo Using CATALINA_HOME2:   "%CATALINA_HOME2%"
echo Using CATALINA_TMPDIR: "%CATALINA_TMPDIR%"
if ""%1"" == ""debug"" goto use_jdk
echo Using JRE_HOME:        "%JRE_HOME%"
goto java_dir_displayed
:use_jdk
echo Using JAVA_HOME:       "%JAVA_HOME%"
:java_dir_displayed
echo Using CLASSPATH:       "%CLASSPATH%"

需要注意的是上面各值的大小需要根据服务器本身的内存大小来设置

 

以上是关于tomcat内存简单调优的主要内容,如果未能解决你的问题,请参考以下文章

tomcat 性能调优

tomcat 性能调优

Tomcat调优——实战

Tomcat调优

tomcat配置调优

Tomcat调优