Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I increase memory on Tomcat 7 when running as a Windows Service?

I am trying to run Tomcat 7 as a Windows Service (XP and Windows 7).

I see places to set the -Xmx and -Xms jvm args in catalina.bat, but I'm not sure how to do it when using $CATALINA_HOME/bin/service.bat install service-name. I looked around but the best I could find was that I needed to update windows registry key, though I'm not sure which one to edit.

I'm hoping there's an easier way, is there?

Update: I'm not using the windows installer mainly because I'm running multiple instances of tomcat on the same machine but with different ports (for reasons I'd rather not go into here). If I can use the installer with multiple instances using different ports, then I'd like to know how, but regardless, is it possible to do increase the memory on a tomcat windows service without the UI tools that come with the installer?

like image 270
Franky Avatar asked May 12 '11 21:05

Franky


People also ask

How much memory should I allocate to Tomcat?

In general, a minimal install requires 4GB for the OS, the tomcat heap XMS setting (default 4GB), 2GB for Retain and any memory the database requires if installed. In all cases, when only the worker is installed the memory is automatically tuned to 3GB.

What is the default heap size in Tomcat 7?

By default, the maximum heap size value is 256 MB.

How much memory is my Tomcat using?

Heap size used by tomcat (as any other java app) is determined by jvm -Xmx param. So if your tomcat runs as a windows service, you would create environment variable CATALINA_OPTS=-Xms64m -Xmx256m. Then, look at the file tomcat-install/bin/catalina.sh (.

What is initial memory pool for Tomcat?

It is recommended for production usage that the Maximum Memory Pool which is the allocation of memory for Apache Tomcat for BI4 usage be set to 4096 MB as a minimum maxmium memory pool setting.


2 Answers

Assuming that you've downloaded and installed Tomcat as Windows Service Installer exe file from the Tomcat homepage, then check the Apache feather icon in the systray (or when absent, run Monitor Tomcat from the start menu). Doubleclick the feather icon and go to the Java tab. There you can configure the memory.

enter image description here

Restart the service to let the changes take effect.

like image 100
BalusC Avatar answered Sep 19 '22 21:09

BalusC


The answer to my own question is, I think, to use tomcat7.exe:

cd $CATALINA_HOME .\bin\service.bat install tomcat .\bin\tomcat7.exe //US//tomcat7 --JvmMs=512 --JvmMx=1024 --JvmSs=1024 

Also, you can launch the UI tool mentioned by BalusC without the system tray or using the installer with tomcat7w.exe

.\bin\tomcat7w.exe //ES//tomcat 

An additional note to this:

Setting the --JvmXX parameters (through the UI tool or the command line) may not be enough. You may also need to specify the JVM memory values explicitly. From the command line it may look like this:

bin\tomcat7w.exe //US//tomcat7 --JavaOptions=-Xmx=1024;-Xms=512;.. 

Be careful not to override the other JavaOption values. You can try updating bin\service.bat or use the UI tool and append the java options (separate each value with a new line).

like image 29
Franky Avatar answered Sep 21 '22 21:09

Franky