Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tune Tomcat 5.5 JVM Memory settings without using the configuration program

I need to configure Tomcat memory settings as part of a larger installation, so manually configuring tomcat with the configuration app after the fact is out of the question. I thought I could just throw the JVM memory settings into the JAVA_OPTS environment variable, but I'm testing that with jconsole to see if it works and it... doesn't.

As per the comment below, CATALINA_OPTS doesn't work either. So far, the only way I can get it to work is via the Tomcat configuration GUI, and that's not an acceptable solution for my problem.

like image 899
red Avatar asked Nov 13 '08 01:11

red


People also ask

What is initial memory pool for Tomcat?

Increase the default Initial memory pool value from 4096 MB to 6144 MB and the default Maximum memory pool value from 6144 MB to 8192 MB, depending on your computer's memory capabilities, then click OK. Start the Tomcat server by navigating to the server\pentaho-server\tomcat\bin folder and double-clicking the startup.

What is Tomcat heap memory?

The Tomcat server is run within a Java Virtual Machine (JVM). This JVM that controls the amount of memory available to LabKey Server. LabKey recommends that the Tomcat web application be configured to have a maximum Java Heap size of at least 2GB for a test server, and at least 4GB for a production server.

What is Tomcat XMX?

-Xmx — The maximum Java heap size in megabytes. By default, the maximum heap size value is 256 MB. -XX:PermSize — This is the initial size for permanent generation (or perm gen). It is the place where Tomcat caches classes and other resources in the memory.


1 Answers

Serhii's suggestion works and here is some more detail.

If you look in your installation's bin directory you will see catalina.sh or .bat scripts. If you look in these you will see that they run a setenv.sh or setenv.bat script respectively, if it exists, to set environment variables. The relevant environment variables are described in the comments at the top of catalina.sh/bat. To use them create, for example, a file $CATALINA_HOME/bin/setenv.sh with contents

export JAVA_OPTS="-server -Xmx512m" 

For Windows you will need, in setenv.bat, something like

set JAVA_OPTS=-server -Xmx768m 

Hope this helps, Glenn

like image 117
Glenn Avatar answered Sep 28 '22 17:09

Glenn