Wednesday, December 23, 2009

How to set Java memory usage of Tomcat 4.1 started as a Windows service

If you try to set Java parameters -Xms or -Xmx in catalina.bat it would work only if you start Tomcat with startup.bat.
If you want to start Tomcat as a service you must dig through registry.
Taken from jguru.

1. Open up the registry (Run -> Regedit)

2. Find the entry for your Tomcat service entry. Either do a search for the service name in the registry or navigate to:
HKEY_LOCAL_MACHINE.SYSTEM.CurrentControlSet.Services.Apache Tomcat 4.1.Parameters

3. You should see several numbered "JVM Option Number" parameters

4. Add two new "String Value" parameters, succeeding the ordinal count of those already there, in my case 4 and 5

5. Add your arguments. I used: -Xms128m and -Xmx128m

6. Modify the JVM Option Count accordingly.

7. Restart your service.