当前位置:网站首页>JVM common instructions

JVM common instructions

2022-06-27 06:04:00 The season when the monsoon dies

Jmap

  Query heap information :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.

View the current number of instances :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: Serial number
  • instances: Number of instances
  • bytes: Occupied space size
  • class name: Class name ,[C is a char[],[S is a short[],[I is a int[],[B is a byte[],[[I is a int[][]

Export memory image :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

see jvm Parameters

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

analysis cpu The reason for that

1. find cpu High thread

top -p pid  -H  # -H It means that it will be printed only once 

 

2. Export the stack information of the thread

C:\Users\41732>jstack 9780  > aa.text

3. Analyze the execution status of the thread in the exported stack information

    Be careful :top -p The output thread number is 10 Base number , and jstack The thread number of the exported file is 16 Base number , Need to transform .

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 Reasons for soaring

  1. thread deadlock
  2. There is an dead loop inside the thread
  3. The program reproduces high-frequency calculations
  4. IO Reading and writing too high
  5. It happens all the time GC
  6. There are too many threads running concurrently

Jstat

  Print GC Information

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>

原网站

版权声明
本文为[The season when the monsoon dies]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206270557284027.html