Tomcat end, JVM status monitoring and memory optimization.

Source: Internet
Author: User
Tags visualvm

This article is suitable for users who have some knowledge about Tomcat and JVM.

Common built-in variables:

Catalina_base // used to set the storage location of files that can have write permissions or custom parts. In applicable scenarios, you need to start multiple Tomcat instances on a node to define multiple catalina_base.

Catalina_opts // defines the JVM running attributes

Java_opts // defines multiple JVM identical running attributes.

Java_home // set the local location when Java or JDK is running.

Jre_home // This is the alias of java_home.

Understand the configuration file:
/Usr/local/tomcat/CONF/Catalina. Policy is used to define the Catalina Security Policy
/Usr/local/tomcat/CONF/Catalina. properties is used to define the Catalina attribute information.

How to adjust the JVM heap memory.

Let's first check the current heap memory size through manager-Gui.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/46/10/wKioL1PtvGyRrIhKAAIvsmApZZU283.jpg "Title =" 9r%2%8rgja%ys0knx8ns%i5.jpg "alt =" wkiol1ptvgyrrihkaaivsmapzzu283.jpg "/>


The current maximum memory is 239.75m. We will adjust it to 512 M.


To define the property information to take effect at startup, You need to define it in the/bin/Catalina. Sh script.

Edit $ catalina_home/bin/Catalina. Sh, search java_opts, and find the prompt segment.

Use the following command to define:

Java_opts = "$ java_opts-xmx512m"

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/46/11/wKiom1Ptv06hBOXwAAGjdeBuFY8631.jpg "Title =" N _ % 57wck % C $ p_q7c ~ Gy9 ~ M6.jpg "alt =" wkiom1ptv06hboxwaagjdebufy8631.jpg "/>

Restart the Tomcat service.

View status

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/46/11/wKiom1PtwI_SUdddAAGXWq3lUTI566.jpg "Title =") @ F ~ 8qr36rg2e8fsbo1jb ~ T.jpg "alt =" wkiom1ptwi_sudddaagxwq3luti566.jpg "/>


Instructions:
-XMS 128 M: sets the minimum memory for JVM running.
-Xmx 256 M: sets the maximum memory for JVM running.
-XX: maxnewsize defines the maximum memory space of the new generation.
-XX: maxpermsize defines the maximum persistent memory space



Next let's take a look at Status Monitoring


Jstat is a JVM monitoring tool. Let's take a look at its usage:

Jstat-<option> <vmid> display frequency [<count>]


Jstat-class PID: displays the number of loaded classes and the occupied space.
Jstat-compiler PID: displays information such as the number of real-time VM compilations.
Jstat-gc pid: displays GC information, the number of GC times, and the time. The last five items are the young GC count, young GC time, full GC count, full GC time, and total GC time.
Jstat-gccapacity: displays the usage and usage of three generations (young, old, and Perm) objects in the VM memory. For example, pgcen displays the minimum perm memory usage, pgcmx displays the maximum memory usage of perm. PGC is the memory usage of the newly generated perm, while PC is the memory usage of the previous perm. For others, the OC usage is pure in old.
Jstat-gcnew PID: information of the new object.
Jstat-gcnewcapacity PID: information about the new object and its usage.
Jstat-gcold PID: information of the old object.
Jstat-gcoldcapacity PID: information about the old object and its usage.
Jstat-gcpermcapacity PID: information of the perm object and its usage.
Jstat-util PID: Statistics of GC information.
Jstat-printcompilation PID: information about the current VM execution.


Example:

  • Jstat-GC 8825 1 s 5

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/46/14/wKioL1PtwzySFOIfAAIO-JIpgJU797.jpg "Title =" W 'DLR % x' w544 ~ Evi@q1_km38.jpg "alt =" wKioL1PtwzySFOIfAAIO-JIpgJU797.jpg "/>

Parameters:

S0: the size of the physical vor space 0 Segment on the heap is kb.
S1: The size of shard vor space 1 on heap is kb.

S0u: the occupied vor space 0 Segment on the heap has used space size kb.

S1u: The used space in Segment 1 of physical vor space on heap is kb.

EC: the size of the Eden space is kb.

EU: The size of space used by Eden is kb.

OC: displays the size of the old space in KB.

Ou: the size of the old space in use is kb.

PC: displays the current persistent space in KB.

Pu: displays the size of the persistent tape used in KB.

Ygc: Number of young GC times from program startup to sampling
Ygct: the time used by young GC (unit: seconds)
FGC: number of full GC times from program startup to sampling
Fgct: the time used for full GC (unit: seconds)
GCT: Total time used for garbage collection (unit: seconds)


Next, we will introduce a graphical monitoring tool, visual VM + visual GC.

Visualvm: http://visualvm.java.net/download.html

If the machine is connected to the Internet, you can add the visualgc plug-in to display more information.

Monitor

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/46/1F/wKioL1Pt2I6CisfXAAN2XKaAcK8645.jpg "Title =" vjmd4 {t_z] 2 {wl2 ~ F6pz'fy.jpg "alt =" wkiol1pt2i6cisfxaan2xkaack8645.jpg "/>

Visual GC

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/46/20/wKioL1Pt2O_Tu7p0AAPkhPnz8RM595.jpg "Title =" {qm4r7e3lrated [2 ~ 2017810000b@cps.jpg "alt =" wkiol1pt2o_tu7p0aapkhpnz8rm595.jpg "/>


References: http://www.cubrid.org/blog/dev-platform/how-to-monitor-java-garbage-collection/


This article from the "bad guy blog" blog, please be sure to keep this source http://tchuairen.blog.51cto.com/3848118/1540695

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.