If you are having performance issues with Tomcat, a common cause is the JVM (Java Virtual Machine) lack of memory allocation. By default, the maximum heap size is 64 or 128 MB. You can increase the maximum application heap size by setting the -Xmx JVM parameter.
For example, -Xmx512m allows the JVM to allocate a maximum of 512 MB of heap. To configure this setting, right-click the My Computer icon and select the Advanced tab. Click the Environment Variables button:
Create variable CATALINA_OPTS and set the desired value, for example “-server -Xmx256m”.
If you are on Linux or UNIX, go to terminal and use the tomcat account using sudo su-tomcat or the appropriate account name, depending on your settings. You must use the account that is used to start Tomcat.
Check both the CATALINA_OPTS and JAVA_OPTS environment variables. Set environment variables to a higher value. For example, if JAVA_OPTS contains a minimum heap size of 64 MB and 128 MB, increase it to 128 MB and 256 MB.
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 you use the maximum value that is less than the size of your physical RAM, otherwise it will be swapped out to the hard drive, which can cause additional performance issues.
To check if the new settings are in effect, go to your Tomcat server URL and click Status:
You should see the new value in the JVM section:
If you have not seen the updated JVM memory on the page, try restarting Tomcat, as parameter changes require restarting Tomcat before they take effect. This should solve your poor Tomcat performance issues, and also avoid running out of memory issues for server side scripts. If you have any questions, let us know in the comments. Enjoy!