Skip to end of metadata
Go to start of metadata

Memory Settings for Tomcat

Tomcat runs as a deamon under Linux or application/service on Windows. Depending on your setup and operating setup please find the instructions to set the memory for Tomcat.

By default, Tomcat sets its own memory size at around 64MB which by far this is not enough for web applications. You can set the "start size", the "maximum size" and you also need to up the heap space. to find out the proper values for your platform you will need to issue the command "java -X" in the terminal.

-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
-Xss<size> set java thread stack size

Once you know your parameters you should allocate about 60% of your available Ram to Tomcat.

Increase Memory

Linux

To set the memory you should have a file called "setenv.sh" in your /tomcat/bin directory. If the file does not exsist you should create it. Within the file set the parameters like;

Then restart Tomcat to apply the new settings.

Windows (started manually)

To set the memory you should have a file called "setenv.bat" in your /tomcat/bin directory. If the file does not exsist you should create it. Within the file set the parameters like;

Then restart Tomcat to apply the new settings.

Windows (as a service)

If you are running Tomcat on a Windows server, then Tomcat should be installed as a service. To set the maximum memory limit of the service, click Start, then *Run..." and type regedt32.

In the registry editor, click to HKEY_LOCAL_MACHINE > SOFTWARE -> Apache Software Foundation -> Procrun 2.0 -> Tomcat> Parameters -> Java. Here you will see an entry for JvmMx, which is the "maximum memory" setting. Double-click JvmMx to edit, change the Base to "Decimal" and adjust the value as necessary.

Permanent Memory Generation

In some cases the server can run out of a different type of memory (Permanent Generation), and if this is the case the above settings may not help solve the memory issue. A problem like this may occur when running multiple applications on the same server.

If you are experiencing this type of error, you would most likely see the following error in your logs:

To increase the level of this memory another java parameter will need to be added:

Linux

As explained above all these settings take place in the setenv.sh. Add the following now;

Windows (started manually)

As explained above all these settings take place in the setenv.bat. Add the following now;

Windows (started as a service)

As mentioned above, for Windows services this is done by editing the service "Options" parameter in the registry.

Subpages
Labels: