Adjust Tomcat startup parameters in Windows
By default, Tomcat can use 128 MB of memory. This is not enough for applications with a large number of shards and relatively high memory consumption. You can adjust the startup parameters of the Java Virtual Machine to increase the memory available for Tomcat.
The following are two well-known parameters.
-Xms <size> JVM initialization heap size
-Xmx <size> maximum JVM heap Value
For example, if I want to set the initial memory size to 128 MB and the maximum usage is 1 GB, the following settings are used:
-Xms128m
-Xmx1024m
In Linux/Unix, you can add or modify JAVA_OPTS in {tomcat_dir}/bin/catalina. sh:
JAVA_OPTS = "-Xms128m-Xmx1024m"
In Windows, you can add or modify JAVA_OPTS in {tomcat_dir}/bin/catalina. bat:
Set JAVA_OPTS =-Xms128m-Xmx1024m
But I installed Tomcat 7 in the Service Startup version on Windows. It does not have the bin/catalina. bat file. How can I change it?
The answer is: Modify the registry.
Run regedit
Find the registry key: HKEY_LOCAL_MACHINE \ SOFTWARE \ Apache Software Foundation
Find Procrun 2.0 \ Tomcat7 \ Parameters \ Java
There is an Options setting
-Dcatalina. home = C: \ Program Files \ Apache Software Foundation \ Tomcat 7.0
-Dcatalina. base = C: \ Program Files \ Apache Software Foundation \ Tomcat 7.0
-Djava. endorsed. dirs = C: \ Program Files \ Apache Software Foundation \ Tomcat 7.0 \ endorsed
-Djava. io. tmpdir = C: \ Program Files \ Apache Software Foundation \ Tomcat 7.0 \ temp
-Djava. util. logging. manager = org. apache. juli. ClassLoaderLogManager
-Djava. util. logging. config. file = C: \ Program Files \ Apache Software Foundation \ Tomcat 7.0 \ conf \ logging. properties
Double-click it to edit it. Add the following two lines at the end:
-Xms128M
-Xmx1024M
Different Versions of Tomcat have different registry keys to be adjusted.
For example:
Tomcat5 is
HKEY_LOCAL_MACHINE \ SOFTWARE \ Apache Software Foundation \ Tomcat Service Manager \ Tomcat5 \ Parameters \ JavaOptions
Tomcat6 is
HKEY_LOCAL_MACHINE \ SOFTWARE \ Apache Software Foundation \ Procrun 2.0 \ Tomcat6 \ Parameters \ Java
Tomcat7 is
HKEY_LOCAL_MACHINE \ SOFTWARE \ Apache Software Foundation \ Procrun 2.0 \ Tomcat7 \ Parameters \ Java
We hereby record it to readers.
Author: codingstandards