For example, -Xmx512m allows maximum 512MB heap to be allocated for the JVM. To adjust this parameter, right click the My Computer icon, then choose the Advanced tab. Click the Environment Variables button:
Create the CATALINA_OPTS variable, 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 using sudo su – tomcat or a corresponding account name depending on your setup. You should use the account that is used to run Tomcat. Check both CATALINA_OPTS and JAVA_OPTS environment 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 click Status:
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!