estadisticas web Skip to content

How to increase Tomcat's memory allocation

How to increase Tomcat's memory allocation

If you experience performance problems with Tomcat, a common cause is the lack of Java Virtual Machine (JVM) memory allocation. The default setting for the maximum heap size is 64 MB or 128 MB. You can increase the maximum application heap size by setting the parameter -Xmx JVM.

For example, -Xmx512m it allows to to allocate a maximum of 512 MB heap for the JVM. To adjust this parameter, right-click on the My Computer icon, then select the tab advanced . Click on the button Environment variables :

Create the variable CATALINA_OPTS and set the desired value, for example " -server -Xmx256m ".

If you are using Linux or UNIX, go to the terminal and use the Tomcat account using sudo su – tomcat or the name of a corresponding account based on your configuration. You should use the account used to run Tomcat.

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

 OLD: JAVA_OPTS = "- Xms64m -Xmx128m -Dsun.rmi.dgc.client.gcInterval = 3600000 -Dsun.rmi.dgc.server.gcInterval = 3600000" OLD: JAVA_OPTS = "- Xms128m -Xmx256m -Dsun.rmi.dgc. client.gcInterval = 3600000 -Dsun.rmi.dgc.server.gcInterval = 3600000 " 

Make sure to use a maximum value that is less than the size of the physical RAM, otherwise it will be paginated on the hard disk, causing further performance problems.

To check if the new settings are effective, go to the URL of your Tomcat server and then click State :

You should see a new value under the JVM section:

If you don't see an updated JVM memory on the page, try restarting Tomcat as parameter changes need to restart Tomcat before they become effective. This should solve your problems with poor Tomcat performance and also avoid memory problems with server-side scripts. If you have any questions, please let us know in the comments. To enjoy!