Sunday, May 2, 2010

how do I set memory related settings to improve Tomcat performance?

When our web application is using large memory as this memory size default setting can be too small, 64MB by default,thus the application becomes slower because the garbage collector is invoked more often, and it can even run out of memory (outofmemory / heap space error ). One way to address this problem is to set a larger heap size . In Windows system, this can be done by editing / adding JAVA_OPTS variable (should be early in the file) in CATALINA_HOME/bin/catalina.bat or catalina.sh for Linux/Unix systems.Parameters to be added are , let say you want to increase it to 256 MB (as you required but make sure you have enough amount of physical memory/RAM and for 32bit system , use no more than 1-1.1 GB heap space size ) , use '-Xms256m -Xmx256m' .In some cases , it is better to set slightly lower size for -Xms . There are other parameters can be added , some of them :'-XX:MaxNewSize -XX:NewSize -XX:MaxPermSize' , depending on your application and requirements .

For catalina.bat there now should be a line in the file that looks like this:  set JAVA_OPTS=-Xms256m -Xmx256m 

For catalina.sh:  JAVA_OPTS='-Xms256m -Xmx256m' 

For other parameters , Try this Apache Link:
http://wiki.apache.org/tomcat/FAQ/Memory
http://wiki.apache.org/tomcat/OutOfMemory

No comments:

Post a Comment