[Appendix] tuning JVM monitoring tool

Jinfo

Extended parameters Java application that you are running
View jvm parameters
Here Insert Picture Description
to view the java system parameters
Here Insert Picture Description

Jstat

jstat command to view the amount of each portion, and the number of loaded classes heap memory. Format command is as follows:
jstat [- command options] [vmid] [interval / ms] [queries]
Note: jdk version is jdk8.
Classloading statistics:
Here Insert Picture Description
Loaded: load class number
Bytes: size of the space occupied by
Unloaded : not loaded quantity
Bytes: not loaded space
time: time

Garbage collection statistics

Here Insert Picture Description
S0C: a first area size surviving
S1C: the size of the second region surviving
S0U: using a size of the first region of surviving
S1U: using the size of the second region surviving
EC: Eden area size
using Eden area: EU size
OC: old's size
OU: old's use of size
MC: method area size (dimensional space)
MU: method area using the size
CCSC: compression class space
CCSU: compression of space use size
YGC: the young generation garbage recycle numbers
YGCT: Young generational garbage collection time-consuming
FGC: the number of old garbage collector's
FGCT: old's garbage collection time-consuming
GCT: total time consuming garbage collection

Heap memory statistics

Here Insert Picture Description
NGCMN:新生代最小容量
NGCMX:新生代最大容量
NGC:当前新生代容量
S0C:第一个幸存区大小
S1C:第二个幸存区的大小
EC:伊甸园区的大小
OGCMN:老年代最小容量
OGCMX:老年代最大容量
OGC:当前老年代大小
OC:当前老年代大小
MCMN:最小元数据容量
MCMX:最大元数据容量
MC:当前元数据空间大小
CCSMN:最小压缩类空间大小
CCSMX:最大压缩类空间大小
CCSC:当前压缩类空间大小
YGC:年轻代gc次数
FGC:老年代GC次数

新生代垃圾回收统计

Here Insert Picture Description
S0C:第一个幸存区的大小
S1C:第二个幸存区的大小
S0U:第一个幸存区的使用大小
S1U:第二个幸存区的使用大小
TT:对象在新生代存活的次数
MTT:对象在新生代存活的最大次数
DSS:期望的幸存区大小
EC:伊甸园区的大小
EU:伊甸园区的使用大小
YGC:年轻代垃圾回收次数
YGCT:年轻代垃圾回收消耗时间

新生代内存统计

Here Insert Picture Description
NGCMN:新生代最小容量
NGCMX:新生代最大容量
NGC:当前新生代容量
S0CMX:最大幸存1区大小
S0C:当前幸存1区大小
S1CMX:最大幸存2区大小
S1C:当前幸存2区大小
ECMX:最大伊甸园区大小
EC:当前伊甸园区大小
YGC:年轻代垃圾回收次数
FGC:老年代回收次数

老年代垃圾回收统计

Here Insert Picture Description
MC:方法区大小
MU:方法区使用大小
CCSC:压缩类空间大小
CCSU:压缩类空间使用大小
OC:老年代大小
OU:老年代使用大小
YGC:年轻代垃圾回收次数
FGC:老年代垃圾回收次数
FGCT:老年代垃圾回收消耗时间
GCT:垃圾回收消耗总时间

老年代内存统计

Here Insert Picture Description
OGCMN:老年代最小容量
OGCMX:老年代最大容量
OGC:当前老年代大小
OC:老年代大小
YGC:年轻代垃圾回收次数
FGC:老年代垃圾回收次数
FGCT:老年代垃圾回收消耗时间
GCT:垃圾回收消耗总时间

元数据空间统计

Here Insert Picture Description
MCMN:最小元数据容量
MCMX:最大元数据容量
MC:当前元数据空间大小
CCSMN:最小压缩类空间大小
CCSMX:最大压缩类空间大小
CCSC:当前压缩类空间大小
YGC:年轻代垃圾回收次数
FGC:老年代垃圾回收次数
FGCT:老年代垃圾回收消耗时间
GCT:垃圾回收消耗总时间
Here Insert Picture Description
S0:幸存1区当前使用比例
S1:幸存2区当前使用比例
E:伊甸园区使用比例
O:老年代使用比例
M:元数据区使用比例
CCS:压缩使用比例
YGC:年轻代垃圾回收次数
FGC:老年代垃圾回收次数
FGCT:老年代垃圾回收消耗时间
GCT:垃圾回收消耗总时间

Jmap

此命令可以用来查看内存信息。

实例个数以及占用内存大小

Here Insert Picture Description
打开log.txt,文件内容如下:
Here Insert Picture Description
num:序号
instances:实例数量
bytes:占用空间大小
class name:类名称

堆信息

Here Insert Picture Description

堆内存dump

Here Insert Picture Description
也可以设置内存溢出自动导出dump文件(内存很大的时候,可能会导不出来)
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=./ (路径)
Here Insert Picture Description
可以用jvisualvm命令工具导入该dump文件分析
Here Insert Picture Description

Jstack

Here Insert Picture Description
Find deadlock with jstack, see example below, you can also view the deadlock with jvisualvm
Here Insert Picture Description

Here Insert Picture Description

Remote connection jvisualvm

Start ordinary jar program JMX port configuration:

java -Dcom.sun.management.jmxremote.port=12345 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.authenticate=false 
-jar foo.jar

The JMX configuration tomcat

JAVA_OPTS=-Dcom.sun.management.jmxremote.port=8999 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.authenticate=false

jvisualvm远程连接服务需要在远程服务器上配置host(连接ip 主机名),并且要关闭防火墙

jstack find the highest occupancy cpu stack information

1, use the command top -p, show case your memory java process, pid is your java process ID, such as 4977
2, according to H, get memory circumstances of each thread
3, memory and cpu usage to find the highest thread tid such as 4977
4 to hexadecimal get 0x1371, this is the hexadecimal representation of the thread id
5, execution jstack 4977 | grep -A 10 1371, get 1371 behind the line of the thread where the thread stack information 10 lines
6, see the corresponding stack information to identify the code that may be problematic

Published 28 original articles · won praise 3 · Views 513

Guess you like

Origin blog.csdn.net/jiaodaguan/article/details/104372974