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

6

42

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?

Mani answered 12/5, 2011 at 21:13 Comment(0)
D
53

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.

Diskson answered 12/5, 2011 at 21:24 Comment(6)
Hai @BalusC, 1. I want to add the -XX:MaxPermSize. If i do like above as u said, is it enough? And also 2. I want to add -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled to catalina batch script. How can I? please guide me...Orebro
@vissu: If you have new questions, press Ask Question button in right top.Diskson
I changed this and save.But when I try to start it again, the tomcat is not being started. Once I change back to default memory size, I am able to start tomcat again.Deem
Or you can just run .\bin\tomcat7w.exe , even if you did not use the installation package.Kudos
The same dialog can be opened by running %CATALINA_HOME%\bin\tomcatXw.exe, where X is major version number. See also tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.htmlThiourea
@Deem you used 32 bit tomcat version.Advice
M
20

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).

Mani answered 13/5, 2011 at 7:9 Comment(2)
You can find more of these options here directory.utk.edu/docs/windows-service-howto.html Also you may need to quote the command line options if they have special characters in them (like when you set a path to javaagent for instance.) One more thing to note, is you can use ++JvmOptions=... to append it to the list instead of -- which removes everything else.Unsure
the ++JvmOptions is safer and enough in most cases, be careful with the --JvmOptions oneTorment
K
7

//ES/tomcat -> This may not work if you have changed the service name during the installation.

Either run the command without any service name

.\bin\tomcat7w.exe //ES

or with exact service name

.\bin\tomcat7w.exe //ES/YourServiceName
Krever answered 16/12, 2011 at 16:56 Comment(0)
R
4

According to catalina.sh customizations should always go into your own setenv.sh (or setenv.bat respectively) eg:

CATALINA_OPTS='-Xms512m -Xmx1024m'

My guess is that setenv.bat will also be called when starting a service.I might be wrong, though, since I'm not a windows user.

Red answered 20/3, 2012 at 8:7 Comment(2)
No. Setenv.bat does not get called when running as a servcie.Chemosphere
downvote: setenv does not get called when running as a windows service.Embolic
A
4

If you are running a custom named service, you should see two executables in your Tomcat/bin directory
In my case with Tomcat 8

08/14/2019  10:24 PM           116,648 Tomcat-Custom.exe
08/14/2019  10:24 PM           119,720 Tomcat-Customw.exe
               2 File(s)        236,368 bytes

Running the "w" terminated executable will let you configure Xmx in the Java tab
enter image description here

Anaclinal answered 5/9, 2019 at 22:10 Comment(2)
This screen is helpful but I needed to use @bkumar's command to open it. The full command is tomcat7w.exe //ES/MyServiceNameOnTaskManagerRainband
@MKYung you can also open the above tomcat properties by going into the bin folder of your installed/extracted tomcat folder, and executing tomcat7w.exe (Sample path: C:\tomcat\bin\tomcat7w.exe)Lac
Z
0

For Tomcat 7 to increase memory :

Identify your service name, you will find it in the service properties, under the "Path to executable" at the end of the line

For me it is //RS//Tomcat70 so the name is Tomcat70

Then write as administrator :

tomcat7.exe //US//Tomcat70 --JvmOptions=-Xmx1024M
Zela answered 9/9, 2019 at 8:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.