Alex
Alex

Reputation: 878

Increase memory size of Apache Tomcat Windows Service for a Java application created by an executable file

We have a legacy Java web application which we deploy to a Windows Server 2012 machine using an executable file and need to increase its memory pool size, since we get a lot of Out of memory exceptions.

It creates its own folders on Program Files including tomcat bin folder and a Windows service named "Apache Tomcat servicename" which is basically Tomcat version 6 but when I try to edit its Java options through tomcat6w.exe it says that this service is not installed on the system.

Is there a way to change the tomcat service being used by the application to a tomcat service installed from http://tomcat.apache.org/

Or maybe edit the service.bat (or any other file?) when creating the executable to hardcode the memory pool size there?

There is a line in service.bat like below:

"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" --JvmMs 128 --JvmMx 256

Upvotes: 4

Views: 8805

Answers (6)

ali4j
ali4j

Reputation: 522

There sould be a file named catalina.bat ( setenv.bat in apache tomcat 7+ ) in the bin directory of tomcat installation. You can add your options to CATALINA_OPS and after restarting tomcat they should be applied. For checking if there applied use jvisualvm (it shows you what options are set for your jvm) .

Upvotes: 0

Siva
Siva

Reputation: 768

Your Tomcat will have two exe files, Tomcat6.exe and Tomcat6w.exe

Suppose your service name is 'MyService' as shown in 'Windows Services', now rename Tomcat6w.exe as MyServicew.exe (notice that there is a 'w' also in the file name).

Now double click this MyServicew.exe, and a intuitive UI is presented for you to Monkey around with the service arguments.

All the best!

Upvotes: 3

Sherin Syriac
Sherin Syriac

Reputation: 495

Try this

  1. Go to windows registry and find directory HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\htfty\Parameters\Java

  2. You can see the parameters JvmMs and JvmMx over there. Change them to desired values and restart service.

Upvotes: 1

Alex
Alex

Reputation: 878

The solution was to edit the Tomcat RAM usage through Registry by running regedit, browsing to:

 HKEY_LOCAL_MACHINE > SOFTWARE > Wow6432Node > ApacheSoftwareFoundation >
   Procrun 2.0 > apache-tomcat > Parameters > Java

and editing following values:

JvmMs  REG_DWORD   0x00000800 (2048)
JvmMx  REG_DWORD   0x00001000 (4096)

The above applies when Tomcat is installed as a Windows Service and through a custom executable file and there is no access to its configuration through the tomcatxw.exe manager.

Upvotes: 2

mdoflaz
mdoflaz

Reputation: 571

It seems like you did not installed Tomcat with JSS installer. You could use tomcat6w if you have installed Tomcat using JSS Installer.

At this point, you need to follow these steps:

  • Run the shortcut located under Start Menu > All Programs > Apache Tomcat x > Configure Tomcat
  • Under the Java tab, make any adjustments for memory pool.
  • Save changes by clicking Apply.
  • Restart Tomcat.

Upvotes: 2

Tushar
Tushar

Reputation: 501

Increase these parameters in service.bat file --JvmMs 128 --JvmMx 256 to --JvmMs 1024 --JvmMx 2048

Upvotes: 1

Related Questions