当前位置:网站首页>JVM常用指令
JVM常用指令
2022-06-27 05:57:00 【季风泯灭的季节】
Jmap
查询堆信息 :jmap -heap pid
C:\Users\41732>jmap -heap 9780
Attaching to process ID 9780, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.152-b16
using thread-local object allocation.
Parallel GC with 4 thread(s)
Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 4267704320 (4070.0M
NewSize = 89128960 (85.0MB)
MaxNewSize = 1422393344 (1356.5M
OldSize = 179306496 (171.0MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875
CompressedClassSpaceSize = 1073741824 (1024.0M
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 65536000 (62.5MB)
used = 36124952 (34.451438903808594MB)
free = 29411048 (28.048561096191406MB)
55.12230224609375% used
From Space:
capacity = 14680064 (14.0MB)
used = 4598376 (4.385353088378906MB)
free = 10081688 (9.614646911621094MB)
31.323950631277903% used
To Space:
capacity = 14680064 (14.0MB)
used = 0 (0.0MB)
free = 14680064 (14.0MB)
0.0% used
PS Old Generation
capacity = 110100480 (105.0MB)
used = 13078136 (12.472282409667969MB)
free = 97022344 (92.52771759033203MB)
11.87836419968378% used
15044 interned Strings occupying 2001648 bytes.查看当前实例个数:jmap -histo pid
num #instances #bytes class name
----------------------------------------------
1: 123030 17393624 [C
2: 42214 13424608 [B
3: 10861 4126040 [I
4: 23535 2071080 java.lang.reflect.Method
5: 70927 1702248 java.lang.String
6: 22263 1075592 [Ljava.lang.Object;
7: 37505 779912 [Ljava.lang.Class;
8: 7161 629160 [Ljava.util.HashMap$Node;
9: 12558 602784 java.util.HashMap
10: 5286 592496 java.lang.Class
11: 16836 538752 java.util.HashMap$Node
12: 9808 470784 org.springframework.core.ResolvableType
13: 12865 411680 java.util.ArrayList$Itr
14: 11799 377568 java.util.concurrent.ConcurrentHashMap$Node
15: 9108 364320 java.util.LinkedHashMap$Entry
16: 7767 310680 java.util.HashMap$KeyIterator
17: 11649 279576 java.lang.StringBuilder
18: 3441 271808 [S
19: 4577 256312 java.util.LinkedHashMap
20: 7391 236512 java.lang.ref.WeakReference
21: 3863 223792 [Ljava.lang.reflect.Method;
22: 2952 212544 java.lang.reflect.Field
23: 5122 195728 [Ljava.lang.String;
24: 7907 189768 java.util.ArrayList
25: 1868 189736 [Z
26: 7011 168264 java.util.Collections$UnmodifiableCollection$1
27: 144 156784 [Ljava.util.concurrent.ConcurrentHashMap$Node;
28: 3869 154760 java.lang.ref.SoftReference- num:序号
- instances:实例数量
- bytes:占用空间大小
- class name:类名称,[C is a char[],[S is a short[],[I is a int[],[B is a byte[],[[I is a int[][]
导出内存影像:jmap ‐dump:format=b,file=fileName pid
C:\Users\41732>jmap -dump:format=b,file=eureka.hprof 9780
Dumping heap to C:\Users\41732\eureka.hprof ...
Heap dump file created
C:\Users\41732>Jinfo
查看jvm参数
C:\Users\41732>jinfo -flags 9780
Attaching to process ID 9780, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.152-b16
Non-default VM flags: -XX:-BytecodeVerificationLocal -XX:-BytecodeVerificationRemote -XX:CICompilerCount=3 -XX:InitialHeapSize=268435456 -XX:MaxHeapSize=4267704320 -XX:MaxNewSize=1422393344 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=891289
60 -XX:OldSize=179306496 -XX:TieredStopAtLevel=1 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC
Command line: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:50964,suspend=y,server=n -XX:TieredStopAtLevel=1 -Xverify:none -Dspring.output.ansi.enabled=always -javaagent:C:\Users\41732\AppData\Local\JetBrains\IntelliJIdea2020.3\c
aptureAgent\debugger-agent.jar -Dfile.encoding=UTF-8
C:\Users\41732>Jstack
分析cpu飙高的原因
1. 找出cpu高的线程
top -p pid -H # -H表示只打印一次
2. 导出线程线程的栈信息
C:\Users\41732>jstack 9780 > aa.text3. 在导出的栈信息中分析该线程正在执行的状态
注意:top -p 输出的线程号是10进制,而jstack导出的文件线程号是16进制,需要转换。

jstack 19332 | grep -10 4b8f"http-nio-8080-ClientPoller-0" #20 daemon prio=5 os_prio=0 tid=0x000000001f6a8000 nid=0x1fb8 runnable [0x0000000020cee000]
java.lang.Thread.State: RUNNABLE
at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
at sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
- locked <0x000000076d2a11e0> (a sun.nio.ch.Util$3)
- locked <0x000000076d2a11d0> (a java.util.Collections$UnmodifiableSet)
- locked <0x000000076d2a1080> (a sun.nio.ch.WindowsSelectorImpl)
at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
at org.apache.tomcat.util.net.NioEndpoint$Poller.run(NioEndpoint.java:1052)
at java.lang.Thread.run(Thread.java:748)
"NioBlockingSelector.BlockPoller-1" #19 daemon prio=5 os_prio=0 tid=0x000000001f680000 nid=0x3c8 runnable [0x0000000020bef000]
java.lang.Thread.State: RUNNABLE
at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(Native Method)
at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
at sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
- locked <0x000000076d061bc8> (a sun.nio.ch.Util$3)
- locked <0x000000076d060b20> (a java.util.Collections$UnmodifiableSet)
- locked <0x000000076d05cdd0> (a sun.nio.ch.WindowsSelectorImpl)
at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
at org.apache.tomcat.util.net.NioBlockingSelector$BlockPoller.run(NioBlockingSelector.java:342)Cpu飙升的原因
- 线程死锁
- 线程内部有死循环
- 程序重有高频率的计算
- IO读写太高
- 频繁的发生GC
- 并发运行中的线程数太多
Jstat
打印GC信息
C:\Users\41732>jstat -gc 9780 1000 10
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
14336.0 14336.0 4490.6 0.0 64000.0 35918.3 107520.0 12771.6 24448.0 23677.6 3200.0 2998.1 6 0.039 1 0.033 0.073
14336.0 14336.0 4490.6 0.0 64000.0 35918.3 107520.0 12771.6 24448.0 23677.6 3200.0 2998.1 6 0.039 1 0.033 0.073
14336.0 14336.0 4490.6 0.0 64000.0 35918.3 107520.0 12771.6 24448.0 23677.6 3200.0 2998.1 6 0.039 1 0.033 0.073
14336.0 14336.0 4490.6 0.0 64000.0 35918.3 107520.0 12771.6 24448.0 23677.6 3200.0 2998.1 6 0.039 1 0.033 0.073
14336.0 14336.0 4490.6 0.0 64000.0 35918.3 107520.0 12771.6 24448.0 23677.6 3200.0 2998.1 6 0.039 1 0.033 0.073
14336.0 14336.0 4490.6 0.0 64000.0 35918.3 107520.0 12771.6 24448.0 23677.6 3200.0 2998.1 6 0.039 1 0.033 0.073
14336.0 14336.0 4490.6 0.0 64000.0 35918.3 107520.0 12771.6 24448.0 23677.6 3200.0 2998.1 6 0.039 1 0.033 0.073
14336.0 14336.0 4490.6 0.0 64000.0 35918.3 107520.0 12771.6 24448.0 23677.6 3200.0 2998.1 6 0.039 1 0.033 0.073
14336.0 14336.0 4490.6 0.0 64000.0 35918.3 107520.0 12771.6 24448.0 23677.6 3200.0 2998.1 6 0.039 1 0.033 0.073
14336.0 14336.0 4490.6 0.0 64000.0 35918.3 107520.0 12771.6 24448.0 23677.6 3200.0 2998.1 6 0.039 1 0.033 0.073
C:\Users\41732>边栏推荐
猜你喜欢

开门小例子学习十种用例图

EasyExcel合并相同内容单元格及动态标题功能的实现

Go日志-Uber开源库zap使用

Assembly language - Wang Shuang Chapter 13 int instruction - Notes

双位置继电器JDP-1440/DC110V

Program ape learning Tiktok short video production
![Navigation [machine learning]](/img/79/8311a409113331e72f650a83351b46.png)
Navigation [machine learning]

使用域名转发mqtt协议,避坑指南

How win 10 opens the environment variables window

双位置继电器HJWS-9440
随机推荐
Go log -uber open source library zap use
Matlab quickly converts two-dimensional coordinates of images into longitude and latitude coordinates
创建一个基础WDM驱动,并使用MFC调用驱动
QT using Valgrind to analyze memory leaks
Program ape learning Tiktok short video production
Built in functions of spark
Senior [Software Test Engineer] learning route and necessary knowledge points
How win 10 opens the environment variables window
Discussion on streaming media protocol (MPEG2-TS, RTSP, RTP, RTCP, SDP, RTMP, HLS, HDS, HSS, mpeg-dash)
Database - index
Opencv implements object tracking
项目-h5列表跳转详情,实现后退不刷新,修改数据则刷新的功能(记录滚动条)
The form verifies the variables bound to the V-model, and the solution to invalid verification
IP网络通信的单播、组播和广播
Two position relay hjws-9440
Mechanical transcoding journal [17] template, STL introduction
Double position relay rxmd2-1mrk001984 dc220v
Junda technology - centralized monitoring scheme for multi brand precision air conditioners
Multithreading basic part part 1
Using domain name forwarding mqtt protocol, pit avoidance Guide