Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use jps,jstat,jstack,jmap, a jvm monitoring tool

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

The jps,jstat,jstack,jmap of the tool commonly used by the ordinary operation and maintenance staff when analyzing jvm is used to analyze the various problems encountered by tomcat.

Common problems with tomcat are:

OOM, thread deadlock (lock dead), lock contention (lock contention), Java consumes too much CPU

Can be analyzed through the above tools

Quick entry of commonly used analysis methods in production:

# jps-- > View the running java process

# jstat-gc process pid-> View the memory usage of the process in the new generation and the old age, the number and time of garbage collection in the younger generation and the older generation

# jstat-gccause process pid-> View the cause of process garbage collection

# jmap-heap process pid-> View the specific usage of process heap memory

# jstack-l process pid-- > View thread information, which is used to analyze the situation in which the thread strives for and deadlock causes tomcat false death.

Jps:java Virtual Machine process View tool

Jps [options] [hostid]

-m: outputs the parameters passed into the main method

-l: displays the full class name of the main

-v: displays the parameters specified for the jvm virtual machine

Common combinations:

# jps-m-l

# jps-m-l-v

[gcct1@localhost bin] $jps-m-l-v5966 org.apache.catalina.startup.Bootstrap start-Djava.util.logging.config.file=/mnt/tomcat/conf/logging.properties-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager-Djava.endorsed.dirs=/mnt/tomcat/endorsed-Dcatalina.base=/mnt/tomcat-Dcatalina.home=/mnt/tomcat-Djava.io.tmpdir=/mnt/tomcat/temp7006 sun.tools.jps.Jps-m-l-v-Denv.class.path=.:/ Usr/java/jdk1.7.0_79/lib/dt.jar:/usr/java/jdk1.7.0_79/lib/tools.jar-Dapplication.home=/usr/java/jdk1.7.0_79-Xms8m

Monitoring of memory usage and garbage collection of jstat:jvm virtual machine during runtime

Jstat-pid: (required)

-options: see what options are available

-gc: when using this option, add the process number of java; for example, jstat-gc 27564 [1s] (you can also keep up with how many times to display)

S0CMagneS1C: indicates the capacity of the first and second survival areas

S0UreS1U: indicates the used capacity of the first and second survival areas

EC,EU: indicates the capacity and usage of the eden area

OC,OU: indicates the capacity and usage of the old area

PC,PU: indicates the memory capacity and usage of the persistent generation

YGC,YGT: indicates the number of times and time consuming of a new generation of GC

FGCT,FGCT: indicates the frequency and time-consuming occurrence of Full GC in the old age

GCT: indicates total GC time elapsed

-gccause:

LGCC: the reason for the last GC

GCC: the reason for the current GC

[gcct1@localhost bin] $jstat-gc 5966 S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT 40960.0 36864.0 36850.3 253952.0 161159.5 109056.0 74574.4 53248.045852.6 19 1.672 3 2.193 3.865 [gcct1@localhost bin] $jstat-gccause 5966 S0 S1 E O P YGC YGCT FGC FGCT GCT LGCC GCC 0.00 99.96 63.76 68.38 86.11 19 1.672 3 2.193 3.865 Allocation Failure No GC

Jmap: view heap memory usage, including the GC algorithm used, heap configuration parameters, and heap memory usage across generations, similar to jstat

-heap: detailed output heap memory usage

-histo: displays all object information

-histo:live: manually triggers the full GC, and then displays the surviving object information (often used for old-age tuning)

-h: get help information

Example: jmap-heap 5966-- > View the detailed usage of heap memory

[gcct1@localhost bin] $jmap-heap 5966Attaching to process ID 5966 Please wait...Debugger attached successfully.Server compiler detected.JVM version is 24.79-b02using thread-local object allocation.Parallel GC with 2 thread (s) Heap Configuration: MinHeapFreeRatio = 0 MaxHeapFreeRatio = 1019215872 (972.0MB) NewSize = 1310720 (1.25MB) MaxNewSize = 17592186044415 MB OldSize = 5439488 (5.1875MB) NewRatio = 2 SurvivorRatio = 8 PermSize = 21757952 (20.75MB) MaxPermSize = 85983232 (82.0MB) G1HeapRegionSize = 0 (0.0MB).

Jstack: view thread stack information within a java process

Jstack [options] pid

-l:long listings (will output complete lock information); jstack-l process number

-m: mixed mode, that is, output java stack and C _ blank + stack information

You can view thread contention, thread deadlock and other information through jstack

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report