Add Tomcat's memory

xiaoxiao2021-03-06  118

Everyone knows that the JVM will allocate an initial memory and maximum memory to this application when the Java program starts. This initial memory and maximum internal existence will affect the performance of the program. For example, when the application uses the maximum memory, JVM is to go to the action of garbage recycling, and release some memory is occupied.

So when you want to adjust Tomcat, initial memory and maximum memory need to be declared to the JVM, and the general Java program can adjust the initial memory and maximum memory of the application through medium -XMS -XMX through medium -XMS -XMX:

Such as: Java -XMS64M -XMX128M A.jar.

The starter of Tomcat is packaged, and Java -x ..... Tomcat. * cannot be used directly to change the settings of the memory. Change this setting in Tomcat

There are two ways:

1. You need to add Tomcat_OPTS, Catalina_opts in the environment variable,

Such as set catalina_opts = -XMS64M -XMX512M;

MS is the smallest, MX is the maximum, 64m, 512m refers to the capacity of memory.

2. Modify the Catalina.bat file

Each line below 166 row "Rem Execute Java with the Applicable Properties"

% _EXECJAVA%% JAVA_OPTS%% CATALINA_OPTS%% DEBUG_OPTS% -Djava.endorsed.dirs = "% JAVA_ENDORSED_DIRS%" -classpath "% CLASSPATH%" -Dcatalina.base = "% CATALINA_BASE%" -Dcatalina.home = "% CATALINA_HOME% "-Djava.io.tmpdir ="% catalina_tmpdir% "% mainclass%% cmd_line_args%% Action% CATALINA_OPTS% replacement into -XMS64M -XMX512M

It is the method

-------------------------------------------------- -------------------------------------------------- ------------

Another method is

In Tomcat_Home / Bin / Catalina.sh file

Find below:

# ----- EXECUTE The Requested Command ------------------------------------------------------------------------------------------------------------------------------ -

Echo "Using Catalina_Base: $ CATALINA_BASE"

Echo "Using Catalina_Home: $ CATALINA_HOME"

Echo "Using Catalina_TMPDir: $ Catalina_TMPDIR"

Echo "Using Java_Home: $ java_home"

Then add a line. .

# ----- EXECUTE The Requested Command ------------------------------------------------------------------------------------------------------------------------------ -

Java_opts = "- Server -xmx512m -xms128m -djava.awt.Headless = True"

Echo "Using Catalina_Base: $ CATALINA_BASE"

Echo "Using Catalina_Home: $ CATALINA_HOME"

echo "Using Catalina_TMPDir: $ CATALINA_TMPDIR" echo "Using Java_Home: $ java_home"

OK is OK.

转载请注明原文地址:https://www.9cbs.com/read-102745.html

New Post(0)