tomcat经常会遇到启动多个项目出现内存溢出的问题,这时就需要进行tomcat优化,增大内存
有两种方式:
1.用命令行打开tomcat时,就需要在tomcat5.5\bin目录下,找到catalina.bat文件修改其文件内容:
找到if not exist "%CATALINA_HOME%\bin\tomcat-juli.jar" goto noJuli
set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="${catalina.base}\conf\logging.properties"
:noJuli标签
在if not exist "%CATALINA_HOME%\bin\tomcat-juli.jar" goto noJuli下面添加命令:
set JAVA_OPTS=%JAVA_OPTS% -server
set JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=512m
set JAVA_OPTS=%JAVA_OPTS% -XX:PermSize=128m -XX:MaxPermSize=256m
set JAVA_OPTS=%JAVA_OPTS% -XX:SurvivorRatio=5 -XX:TargetSurvivorRatio=90
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=9000
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.authenticate=false
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false
添加后就成为:
if not exist "%CATALINA_HOME%\bin\tomcat-juli.jar" goto noJuli
set JAVA_OPTS=%JAVA_OPTS% -server
set JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=512m
set JAVA_OPTS=%JAVA_OPTS% -XX:PermSize=128m -XX:MaxPermSize=256m
set JAVA_OPTS=%JAVA_OPTS% -XX:SurvivorRatio=5 -XX:TargetSurvivorRatio=90
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=9000
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.authenticate=false
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false
set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties"
:noJuli
此时完成tomcat优化
2.用Eclipse打开tomcat时,就需要在Eclipse中设置,window->Preferences->Tomcat->JVM Settings->Append to JVM Paramters->add
开始一条一条的添加:-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=9000
-Dcom.sun.management.jmxremote
-XX:SurvivorRatio=5 -XX:TargetSurvivorRatio=90
-XX:PermSize=128m -XX:MaxPermSize=256m
-Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=512m
-server
然后 Apply->ok
此时,完成tomcat在Eclipse中的性能优化
有两种方式:
1.用命令行打开tomcat时,就需要在tomcat5.5\bin目录下,找到catalina.bat文件修改其文件内容:
找到if not exist "%CATALINA_HOME%\bin\tomcat-juli.jar" goto noJuli
set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="${catalina.base}\conf\logging.properties"
:noJuli标签
在if not exist "%CATALINA_HOME%\bin\tomcat-juli.jar" goto noJuli下面添加命令:
set JAVA_OPTS=%JAVA_OPTS% -server
set JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=512m
set JAVA_OPTS=%JAVA_OPTS% -XX:PermSize=128m -XX:MaxPermSize=256m
set JAVA_OPTS=%JAVA_OPTS% -XX:SurvivorRatio=5 -XX:TargetSurvivorRatio=90
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=9000
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.authenticate=false
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false
添加后就成为:
if not exist "%CATALINA_HOME%\bin\tomcat-juli.jar" goto noJuli
set JAVA_OPTS=%JAVA_OPTS% -server
set JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=512m
set JAVA_OPTS=%JAVA_OPTS% -XX:PermSize=128m -XX:MaxPermSize=256m
set JAVA_OPTS=%JAVA_OPTS% -XX:SurvivorRatio=5 -XX:TargetSurvivorRatio=90
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=9000
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.authenticate=false
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false
set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties"
:noJuli
此时完成tomcat优化
2.用Eclipse打开tomcat时,就需要在Eclipse中设置,window->Preferences->Tomcat->JVM Settings->Append to JVM Paramters->add
开始一条一条的添加:-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=9000
-Dcom.sun.management.jmxremote
-XX:SurvivorRatio=5 -XX:TargetSurvivorRatio=90
-XX:PermSize=128m -XX:MaxPermSize=256m
-Xms1024m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=512m
-server
然后 Apply->ok
此时,完成tomcat在Eclipse中的性能优化