TomcatExpert

memory

Ask the Experts : Configure Tomcat Memory Settings

Need to configure a linux (RedHat AS4) Tomcat 6.0.32 server's memory settings. After reviewing numerous guides about confiugring tomcat's memory, I realized I am seriously confused.  I attempted to configure the heap memory by adding setenv.sh file to the /opt/apache-tomcat-6.0.32/bin folder.  Here is the content of setenv.sh file.
      export CATALINA_OPTS="-Xms768m -Xmx768m"

asked by chill

question

You are on the right track.

You have...

 - created "bin/setenv.sh"
 - exported the CATALINA_OPTS environment variable
 - added the settings to configure the initial and max heap values to 768m

You just need to...

  - add -XX:PermSize and -XX:MaxPermSize to CATALINA_OPTS to configure PermGen to be 512M.
  - add -XX:NewSize and -XX:MaxNewSize to CATALINA_OPTS to configure YoungGen to be 200M.
  - restart your Tomcat instance

One note, unless you really, really know what you are doing I wouldn't recommend explicitly configuring the size of the YoungGen space.  The JVM does a great job of sizing this automatically.  Unless you have done some serious load testing on your application or you have been given exact instructions by a 3td party vendor, I would suggest just using the defaults.

Lastly, there are a couple ways that you can confirm that your settings are working.

1.) Run "ps aux | grep catalina" (or some other version of the "ps" command).  Look at your Tomcat process.  You should see all of the options that you've put into CATALINA_OPTS (and many more) included on the command line for your process.  If you see them listed here then they are active.

2.) Connect to Tomcat with "jconsole", click the "VM Summary" tab and look at the "VM arguments" section.  Again, you should see the options that you added to CATALINA_OPTS listed here.

3.) Run "jinfo <tomcat-pid>".  The last thing it prints will be the VM Flags.  These should include the options that you've specified in CATALINA_OPTS.


Lastly, I would suggest that you read these two articles.  This is more than just a shameless plug for my posts smiley.  They were written to gently introduce people to the concepts of JVM tuning (for Tomcat).  Furthermore, when you feel that you understand the topics presented in the article, you can progress along to the more advanced articles in the links.  This gentle progression should help take some of the confusion out of JVM tuning.

  http://www.tomcatexpert.com/blog/2011/11/16/setting-measurement-garbage-collection-apache-tomcat
  http://www.tomcatexpert.com/blog/2011/11/22/performance-tuning-jvm-running-tomcat

Hope that helps!

answered by dmikusa on January 10, 2012 07:32 AM

Read More

answer

0 comments   |  

0
Rating
  |  

Operations | memory

Syndicate content