Tomcat Memory Settings

Document ID : KB000088581
Last Modified Date : 14/04/2018
Show Technical Document Details
Issue:

Symptoms

OutOfMemoryErrors in Tomcat


Cause

The default memory settings of Tomcat are usually very low, especially regarding the PermGenSpace.



 

Resolution:

Please set the Maximum PermGenSpace to at least 256mb and the maximum heap space to the maximum you can expect to fit into physical memory. How to do this varies depending on where and how you install Tomcat (e.g. environment variables on Unix, tomcat7w.exe when using the Windows installer), so please consult the documentation applicable for your installation before applying the settings described here.

Running Tomcat as a Windows service:
In this scenario, please open tomcat7w.exe, the configuration tool for tomcat, switch to the Java tab, and 

  1. add "-XX:MaxPermSize=256m" (without the qoutes) as a separate line
  2. set the "Maximum memory pool" setting to a value that will fit into your physical memory.

as shown in the following screenshot (here we assume that we can fit 8192mb into main memory).

 .png

When using Tomcat on Windows (but not as a service) or on a Linux system
In this scenario, the startup scripts of Tomcat will pass the values in the CATALINA_OPTS environment variable to the JVM. To apply the same settings from the previous example, you would set the value to "-Xmx8192m -XX:MaxPermSize=256m" (without the quotes).

Note: With a 32 bit JVM, the maximum possible heap space is severely restricted. We recommend a 64bit JVM to be able to use all available RAM if necessary.