How to Increase Tomcat’s Memory Allocation

Helps to reduce poor performance issues

If you are experiencing performance issues with Tomcat, a common cause is the lack of JVM (Java Virtual Machine) memory allocation. The default setting of the maximum heap size is 64MB or 128MB. You can increase the maximum heap size of applications by setting the-XmxJVM parameter.

For example,-Xmx512mallows maximum 512MB heap to be allocated for the JVM. To adjust this parameter, right click the My Computer icon, then choose theAdvancedtab. Click theEnvironment Variablesbutton:

Create theCATALINA_OPTSvariable, and set the desired value, for example “-server -Xmx256m“.

If you are running on Linux or UNIX, go to the terminal and use the tomcat account by usingsudo su – tomcator a corresponding account name depending on your setup.  You should use the account that is used to run Tomcat.

Check bothCATALINA_OPTSandJAVA_OPTSenvironment variables.  Set the environment variables to a higher value. For example, if the JAVA_OPTS variable is containing a minimum of 64MB and 128MB maximum heap size, increase it to 128MB and 256MB values.

Make sure to use a maximum value that is less than your physical RAM’s size, otherwise it will be paged to the hard disk, which could cause more performance issues.

To check if the new settings are in effect, go to the URL of your Tomcat server and then clickStatus:

You should see a new value under the JVM section:

If you did not see an updated JVM memory on the page, try restarting Tomcat as parameter changes need a Tomcat restart before taking effect. This should fix your issues on poor Tomcat performance and also avoid out of memory problems with your server side scripts. If you have questions, let us know in the comments. Enjoy!

Founder of Help Desk Geek and managing editor. He began blogging in 2007 and quit his job in 2010 to blog full-time. He has over 15 years of industry experience in IT and holds several technical certifications.Read Aseem’s Full Bio

Welcome to Help Desk Geek- a blog full of tech tips from trusted tech experts. We have thousands of articles and guides to help you troubleshoot any issue. Our articles have been read over 150 million times since we launched in 2008.

HomeAbout UsEditorial StandardsContact UsTerms of Use

Copyright © 2008-2024 Help Desk Geek.com, LLC All Rights Reserved