Tomcat sets cache size

Source: Internet
Author: User

Java runtime platform JVM (java Virtual Machine) When an application is started, the virtual machine must allocate the most memory and the minimum memory to it. For JAVA, where the memory is crazy, the initial memory and the maximum memory will have a great impact on the performance of the application. For example, when our application uses the maximum memory quota provided by JVM, JVM has to stop our application first.
Sort the work to find garbage that can be returned (release memory occupied by useless objects), and release some occupied memory.

Generally, we add the parameter-X when starting the java program for the maximum and minimum values of our quota.
MS-Xmx to adjust the initial memory and maximum memory of the application, where Xms represents the minimum quota, Xmx represents the maximum quota
.


Some time ago, when I used resin (a free JSP running platform), I set these two parameters in the startup file, but changed tomcat (a very useful JSP running platform)
And later,

Tomcat (a very useful JSP running platform) is not started as a common java program, it is encapsulated, so the two parameters are set
But as long as it is a java program, there is always a place to set this parameter.

After finding some information, we can solve the problem in the following two ways:

1. You need to add tomcat (a good JSP running platform) _ OPTS and CATALINA_OPTS to the environment variables,
For example, SET CATALINA_OPTS =-Xms64m-Xmx512m;
Ms is the smallest, mx is the largest, 64 m, m respectively refers to the memory capacity.

2. Modify the Catalina. bat file
In line 1, "rem Execute Java with the applicable properties ",
% _ EXECJAVA % JAVA_OPTS % CATALINA_OPTS % DEBUG_OPTS %-Djava. endorsed. dirs = "% JA
VA_ENDORSED_DIRS % "-classpath" % CLASSPATH % "-Dcatalina. base =" % CATALINA_BASE %"
-Dcatalina. home = "% CATALINA_HOME %"-Djava. io. tmpdir = "% CATALINA_TMPDIR %" % MAINCL
Replace % CATALINA_OPTS % in ASS % CMD_LINE_ARGS % ACTION % with-Xms64m-Xmx512m

 

E. g
Update file:
Omcat (a good JSP running platform) incatalina. bat
Update the line
Set JAVA_OPTS =-Xmx256M-Xms64M
Means max cache & min cache

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.