Need to configure a linux Tomcat 6.0.32 server’s memory settings. After reviewing numerous guides about configuring 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”
The server rebooted properly, but I could find nothing in any logs to indicate if I was successful.
Here is the memory configuration which needs to be done.
Heap Space = 768 MB
PermGen space = 512 MB
Eden Space = 200 MB
After some goggling I got,
– 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 that would help to take some of the confusion out of JVM tuning.