JVM的分析工具

1、簡介

名稱 功能 經常使用命令
jps 顯示java程序 jps -l
jinfo 顯示java進程信息:pid、system Properties 及 arg[] jinfo pid
jconsole
jstat java實時監控工具:通常用來調優(gc) jstat -gc pid 間隔 次數
jstack java實時監控工具:打印棧信息,通常用來調優、線程運行狀況(鎖) jstack -l pid
jmap 是打印堆內存信息,通常都是找BUG,如:死鎖、對象大小等等,將數據存放下來,而後在本分析 jmap -histo pid > 1.txt/jmap -dump:format=b,file=1.bin pid

jmap、jstatck和jstat的區別是

  • jmap:是打印堆內存信息,通常都是找BUG,如:死鎖、對象大小等等,將數據存放下來,而後在本分析。
  • jstack:獲取JVM中線程的信息,用於查找性能點,死鎖等。
  • jstat:打印gc、class、compiler的實時信息,通常用來調優

2、jps [host]

列出主機上的進程(-v列出具體的信息)

[root@1 tomcat]#  jps -v

13781 Jps -Denv.class.path=/usr/local/jdk1.7.0_79/lib:/usr/local/jdk1.7.0_79/jre/lib -Dapplication.home=/usr/local/jdk1.7.0_79 -Xms8m
17541 -- process information unavailable
14661 -- process information unavailable
12224 -- process information unavailable
26343 Bootstrap -Djava.util.logging.config.file=/data/project/dlmall_tomcat_8080/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/data/project/dlmall_tomcat_8080/endorsed -Dcatalina.base=/data/project/dlmall_tomcat_8080 -Dcatalina.home=/data/project/dlmall_tomcat_8080 -Djava.io.tmpdir=/data/project/dlmall_tomcat_8080/temp
28134 -- process information unavailable
8167 -- process information unavailable
19265 -- process information unavailable
14703 -- process information unavailable
13482 -- process information unavailable
15683 -- process information unavailable
1742 Bootstrap -Djava.util.logging.config.file=/data/project/dlmall_tomcat_8080/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/data/project/dlmall_tomcat_8080/endorsed -Dcatalina.base=/data/project/dlmall_tomcat_8080 -Dcatalina.home=/data/project/dlmall_tomcat_8080 -Djava.io.tmpdir=/data/project/dlmall_tomcat_8080/temp
1300 Bootstrap -Djava.util.logging.config.file=/data/project/usercenter_tomcat_10224/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/data/project/usercenter_tomcat_10224/endorsed -Dcatalina.base=/data/project/usercenter_tomcat_10224 -Dcatalina.home=/data/project/usercenter_tomcat_10224 -Djava.io.tmpdir=/data/project/usercenter_tomcat_10224/temp
9356 -- process information unavailable
14781 -- process information unavailable
15357 -- process information unavailable
15019 -- process information unavailable
16988 -- process information unavailable
6308 -- process information unavailable

3、jinfo 輸出java進程的信息

[root@1 tomcat]# jinfo 15357
Attaching to process ID 15357, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.79-b02
Java System Properties:

java.runtime.name = Java(TM) SE Runtime Environment
java.vm.version = 24.79-b02
sun.boot.library.path = /usr/local/jdk1.7.0_79/jre/lib/amd64
shared.loader = 
java.vendor.url = http://java.oracle.com/
java.vm.vendor = Oracle Corporation
path.separator = :
file.encoding.pkg = sun.io
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
java.util.logging.config.file = /data/project/dlpublic_tomcat_10216/conf/logging.properties
tomcat.util.buf.StringCache.byte.enabled = true
sun.os.patch.level = unknown
sun.java.launcher = SUN_STANDARD
user.country = US
user.dir = /data/project
java.vm.specification.name = Java Virtual Machine Specification
java.runtime.version = 1.7.0_79-b15
org.apache.catalina.startup.TldConfig.jarsToSkip = tomcat7-websocket.jar
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
os.arch = amd64
java.endorsed.dirs = /data/project/dlpublic_tomcat_10216/endorsed
line.separator = 

java.io.tmpdir = /data/project/dlpublic_tomcat_10216/temp
java.vm.specification.vendor = Oracle Corporation
java.util.logging.manager = org.apache.juli.ClassLoaderLogManager
java.naming.factory.url.pkgs = org.apache.naming
os.name = Linux
sun.jnu.encoding = UTF-8
java.library.path = /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
tomcat.util.scan.DefaultJarScanner.jarsToSkip = bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,websocket-api.jar,catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-tribes.jar,jasper.jar,jasper-el.jar,ecj-*.jar,tomcat-api.jar,tomcat-util.jar,tomcat-coyote.jar,tomcat-dbcp.jar,tomcat-jni.jar,tomcat-spdy.jar,tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,tomcat-jdbc.jar,tools.jar,commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,commons-math*.jar,commons-pool*.jar,jstl.jar,taglibs-standard-spec-*.jar,geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,jmx-tools.jar,jta*.jar,log4j.jar,log4j-1*.jar,mail*.jar,slf4j*.jar,xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,junit.jar,junit-*.jar,hamcrest*.jar,org.hamcrest*.jar,ant-launcher.jar,cobertura-*.jar,asm-*.jar,dom4j-*.jar,icu4j-*.jar,jaxen-*.jar,jdom-*.jar,jetty-*.jar,oro-*.jar,servlet-api-*.jar,tagsoup-*.jar,xmlParserAPIs-*.jar,xom-*.jar
java.class.version = 51.0
java.specification.name = Java Platform API Specification
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
os.version = 3.10.0-229.el7.x86_64
user.home = /home/tomcat
org.apache.catalina.startup.ContextConfig.jarsToSkip = 
user.timezone = Asia/Chungking
catalina.useNaming = true
java.awt.printerjob = sun.print.PSPrinterJob
file.encoding = UTF-8
java.specification.version = 1.7
catalina.home = /data/project/dlpublic_tomcat_10216
user.name = tomcat
java.class.path = /data/project/dlpublic_tomcat_10216/bin/bootstrap.jar:/data/project/dlpublic_tomcat_10216/bin/tomcat-juli.jar
java.naming.factory.initial = org.apache.naming.java.javaURLContextFactory
package.definition = sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.naming.,org.apache.tomcat.
java.vm.specification.version = 1.7
sun.arch.data.model = 64
sun.java.command = org.apache.catalina.startup.Bootstrap start
java.home = /usr/local/jdk1.7.0_79/jre
user.language = en
java.specification.vendor = Oracle Corporation
awt.toolkit = sun.awt.X11.XToolkit
java.vm.info = mixed mode
java.version = 1.7.0_79
java.ext.dirs = /usr/local/jdk1.7.0_79/jre/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path = /usr/local/jdk1.7.0_79/jre/lib/resources.jar:/usr/local/jdk1.7.0_79/jre/lib/rt.jar:/usr/local/jdk1.7.0_79/jre/lib/sunrsasign.jar:/usr/local/jdk1.7.0_79/jre/lib/jsse.jar:/usr/local/jdk1.7.0_79/jre/lib/jce.jar:/usr/local/jdk1.7.0_79/jre/lib/charsets.jar:/usr/local/jdk1.7.0_79/jre/lib/jfr.jar:/usr/local/jdk1.7.0_79/jre/classes
server.loader = 
java.vendor = Oracle Corporation
catalina.base = /data/project/dlpublic_tomcat_10216
file.separator = /
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
common.loader = ${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
package.access = sun.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.naming.resources.,org.apache.tomcat.
dlpublic.root = /data/project/dlpublic_tomcat_10216/temp/0-ROOT/
sun.cpu.isalist = 

VM Flags:

-Djava.util.logging.config.file=/data/project/dlpublic_tomcat_10216/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -XX:PermSize=64M -XX:MaxPermSize=128m -Xms512M -Xmx1024M -XX:MaxNewSize=64m -Djava.endorsed.dirs=/data/project/dlpublic_tomcat_10216/endorsed -Dcatalina.base=/data/project/dlpublic_tomcat_10216 -Dcatalina.home=/data/project/dlpublic_tomcat_10216 -Djava.io.tmpdir=/data/project/dlpublic_tomcat_10216/temp

4、jconsole

在CMD中使用jconsole 會使用jconsole的分析工具

5、jmap

用途:觀察運行中的jvm物理內存的佔用狀況,包括Heap size, Perm size等等。

-heap:打印jvm heap的狀況

-histo:打印jvm heap的直方圖。其輸出信息包括類名,對象數量,對象佔用大小。

-histo:live :同上,可是隻答應存活對象的狀況

-permstat:打印permanent generation heap狀況

打印對象java

[tomcat@1 ~]$ jmap -histo 6308 > 1.txt
[tomcat@1 ~]$ less 1.txt

 num     #instances         #bytes  class name
----------------------------------------------
   1:        798603       60145800  [C
   2:        138032       51259048  [B
   3:        138630       22365576  <constMethodKlass>
   4:         15705       17838152  <constantPoolKlass>
   5:        138630       17761120  <methodKlass>
   6:        100021       15367808  [I
   7:         15705       11664816  <instanceKlassKlass>
   8:         12995        9695776  <constantPoolCacheKlass>
   9:        401014        9624336  java.lang.String
  10:        117855        5835624  [Ljava.lang.Object;
  11:        125178        4005696  java.util.HashMap$Entry
  12:         50001        4000080  java.lang.reflect.Method
  13:         82636        3966528  java.nio.HeapCharBuffer
  14:          6165        3514376  <methodDataKlass>
  15:         32845        3463040  [Ljava.util.HashMap$Entry;
  16:         83804        3352160  java.util.LinkedHashMap$Entry
  17:         24894        2904600  [S
  18:         42082        2356592  java.util.LinkedHashMap
  19:         30932        1979648  java.util.regex.Matcher
  20:         16413        1547616  java.lang.Class
  21:         56050        1345200  java.util.ArrayList
  22:         24454        1202360  [[I
  23:         24325        1167600  java.util.HashMap
  24:         36116        1155712  java.util.Hashtable$Entry
  25:         35515        1136480  java.util.concurrent.ConcurrentHashMap$HashEntry
  26:         42637        1023288  java.lang.StringBuilder
  27:         15876        1016064  java.net.URL
  28:         40710         977040  java.util.concurrent.atomic.AtomicLong
  29:         12530         902160  java.lang.reflect.Field
  30:         17962         840968  [Ljava.lang.String;
  31:         17976         719040  java.lang.ref.SoftReference
  32:         21678         693696  java.lang.StackTraceElement
  33:         21284         681088  java.lang.ref.WeakReference
  34:         27898         669552  java.io.ObjectInputStream$HandleTable$HandleList
  35:         16683         667320  java.util.TreeMap$Entry
  36:          8901         640872  java.lang.reflect.Constructor
  37:         29741         618280  [Ljava.lang.Class;

  7042:             1             16  sun.reflect.GeneratedMethodAccessor201
  7043:             1             16  org.apache.commons.collections.iterators.EmptyOrderedMapIterator
  7044:             1             16  com.google.inject.internal.guava.collect.$Iterators$1
  7045:             1             16  sun.reflect.GeneratedMethodAccessor736
  7046:             1             16  jenkins.branch.NoTriggerOrganizationFolderProperty$Dispatcher
  7047:             1             16  jenkins.model.GlobalNodePropertiesConfiguration$$FastClassByGuice$$e6707da1
  7048:             1             16  sun.reflect.GeneratedMethodAccessor29
  7049:             1             16  hudson.cli.ListPluginsCommand$$FastClassByGuice$$9650998a
  7050:             1             16  sun.reflect.GeneratedMethodAccessor438
  7051:             1             16  sun.reflect.GeneratedMethodAccessor474
  7052:             1             16  sun.reflect.GeneratedMethodAccessor699
  7053:             1             16  hudson.plugins.deploy.DeployPublisher$DescriptorImpl$$FastClassByGuice$$ef30e0c4
  7054:             1             16  hudson.matrix.DefaultMatrixExecutionStrategyImpl$DescriptorImpl$$FastClassByGuice$$ce3ec170
  7055:             1             16  org.jenkinsci.bytecode.Transformer
  7056:             1             16  net.sf.json.util.JavaIdentifierTransformer$UnderscoreJavaIdentifierTransformer
  7057:             1             16  java.security.ProtectionDomain$1
  7058:             1             16  org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher$__sisu12$$FastClassByGuice$$6869d82e
  7059:             1             16  hudson.plugins.emailext.plugins.trigger.FailureTrigger$DescriptorImpl$$FastClassByGuice$$9cb01b39
  7060:             1             16  sun.reflect.GeneratedMethodAccessor804
Total       3662258      295584784

打印堆中的信息react

[tomcat@1 ~]$ jmap -heap  6308
Attaching to process ID 6308, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.79-b02

using thread-local object allocation.
Parallel GC with 4 thread(s)

Heap Configuration:
   MinHeapFreeRatio = 0
   MaxHeapFreeRatio = 100
   MaxHeapSize      = 1073741824 (1024.0MB)
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 134217728 (128.0MB)
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 268435456 (256.0MB)
   MaxPermSize      = 536870912 (512.0MB)
   G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 110100480 (105.0MB)
   used     = 7671208 (7.315834045410156MB)
   free     = 102429272 (97.68416595458984MB)
   6.96746099562872% used
From Space:
   capacity = 12058624 (11.5MB)
   used     = 6324288 (6.03131103515625MB)
   free     = 5734336 (5.46868896484375MB)
   52.44618291440217% used
To Space:
   capacity = 11534336 (11.0MB)
   used     = 0 (0.0MB)
   free     = 11534336 (11.0MB)
   0.0% used
PS Old Generation
   capacity = 402653184 (384.0MB)
   used     = 101235008 (96.54522705078125MB)
   free     = 301418176 (287.45477294921875MB)
   25.14198621114095% used
PS Perm Generation
   capacity = 268435456 (256.0MB)
   used     = 88806056 (84.69205474853516MB)
   free     = 179629400 (171.30794525146484MB)
   33.082833886146545% used

38659 interned Strings occupying 4321264 bytes.

打印內存信息,生成2進制文件,用來分析web

[tomcat@1 ~]$ jmap -dump:format=b,file=1.bin 6308
Dumping heap to /home/tomcat/1.bin ...
Heap dump file created
##會生成一個2進制文件,而後能夠加載到本地來分析。

6、jstat

  • jstat:java實時監控工具,通常用來調優(gc)
  • 命令
jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]
  • 參數
-class:統計class loader行爲信息

-compile:統計編譯行爲信息

-gc:統計jdk gc時heap信息

-gccapacity:統計不一樣的generations(不知道怎麼翻譯好,包括新生區,老年區,permanent區)相應的heap容量狀況

-gccause:統計gc的狀況,(同-gcutil)和引發gc的事件

-gcnew:統計gc時,新生代的狀況

-gcnewcapacity:統計gc時,新生代heap容量

-gcold:統計gc時,老年區的狀況

-gcoldcapacity:統計gc時,老年區heap容量

-gcpermcapacity:統計gc時,permanent區heap容量

-gcutil:統計gc時,heap狀況
  • 打印class的實時數據
打印pid=6308的實時class信息,沒1000ms打印一次,總共打印5次
[tomcat@1 ~]$ jstat -class 6308 1000 5
Loaded  Bytes  Unloaded  Bytes     Time   
 18861 34897.7     3122  3776.6      11.91
 18861 34897.7     3122  3776.6      11.91
 18861 34897.7     3122  3776.6      11.91
 18861 34897.7     3122  3776.6      11.91
 18861 34897.7     3122  3776.6      11.91
  • 打印實時編譯的class
[tomcat@1 ~]$ jstat -compiler 6308
Compiled Failed Invalid   Time   FailedType FailedMethod 
    3780      1       0   120.26          2 com/xxx/xxx run
  • 打印gc的信息參數信息
S0C:Current survivor space 0 capacity (當前S0的大小).

S1C:Current survivor space 1 capacity (KB).

S0U:Current survivor space 0 utilization (KB)(當前S0的可用大小).

S1U:Current survivor space 1 utilization(KB).

EC:Current eden space capacity(KB).

EU:Eden space utilization(KB).

OC:Current old space capacity(KB).

OU:Old space utilization (KB).

PC:Current permanent space capacity (KB).

PU:Permanent space utilization (KB).

YGC:Number of young generation GC Events.

YGCT:Young generation garbage collection time.

FGC:Number of full GC events.

FGCT:Full garbage collection time.

GCT:Total garbage collection time.
  • 打印gc的信息(百分比)
[tomcat@1 ~]$ jstat -gcutil 6308 1000 5
  S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT   
  0.00   3.13  24.21  26.43  33.11    987   13.012     3    2.524   15.536
  0.00   3.13  24.21  26.43  33.11    987   13.012     3    2.524   15.536
  0.00   3.13  24.21  26.43  33.11    987   13.012     3    2.524   15.536
  0.00   3.13  24.21  26.43  33.11    987   13.012     3    2.524   15.536
  0.00   3.13  24.21  26.43  33.11    987   13.012     3    2.524   15.536
  • 打印gc數據(具體)
[tomcat@1 ~]$ jstat -gc 6308 1000 5 
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       PC     PU    YGC     YGCT    FGC    FGCT     GCT   
12288.0 14336.0 7776.0  0.0   102400.0  1417.3   393216.0   103757.4  262144.0 86786.8    984   12.989   3      2.524   15.513
12288.0 14336.0 7776.0  0.0   102400.0  1473.8   393216.0   103757.4  262144.0 86786.8    984   12.989   3      2.524   15.513
12288.0 14336.0 7776.0  0.0   102400.0  1491.6   393216.0   103757.4  262144.0 86786.8    984   12.989   3      2.524   15.513
12288.0 14336.0 7776.0  0.0   102400.0  1495.8   393216.0   103757.4  262144.0 86786.8    984   12.989   3      2.524   15.513
12288.0 14336.0 7776.0  0.0   102400.0  1510.6   393216.0   103757.4  262144.0 86786.8    984   12.989   3      2.524   15.513
  • 打印perm、new、old的信息
[tomcat@1 ~]$ jstat -gccapacity 6308 1000 5
 NGCMN    NGCMX     NGC     S0C   S1C       EC      OGCMN      OGCMX       OGC         OC      PGCMN    PGCMX     PGC       PC     YGC    FGC 
131072.0 131072.0 131072.0 14336.0 14848.0 101376.0   393216.0   917504.0   393216.0   393216.0 262144.0 524288.0 262144.0 262144.0    987     3
131072.0 131072.0 131072.0 14336.0 14848.0 101376.0   393216.0   917504.0   393216.0   393216.0 262144.0 524288.0 262144.0 262144.0    987     3
131072.0 131072.0 131072.0 14336.0 14848.0 101376.0   393216.0   917504.0   393216.0   393216.0 262144.0 524288.0 262144.0 262144.0    987     3
131072.0 131072.0 131072.0 14336.0 14848.0 101376.0   393216.0   917504.0   393216.0   393216.0 262144.0 524288.0 262144.0 262144.0    987     3
131072.0 131072.0 131072.0 14336.0 14848.0 101376.0   393216.0   917504.0   393216.0   393216.0 262144.0 524288.0 262144.0 262144.0    987     3

7、jstack

  • jstack:打印棧信息,java實時監控工具,通常用來調優(鎖)
  • 命令
jstack [-l] <pid>
  • 參數
-l:列出當前java應用的線程狀態
  • top列出CPU消耗高的java應用
[tomcat@idanlu-kaifa-63 ~]$ top
top - 13:59:44 up 63 days, 21:46,  5 users,  load average: 0.15, 0.15, 0.19
Tasks: 169 total,   1 running, 168 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.7 us,  1.3 sy,  0.0 ni, 96.9 id,  0.0 wa,  0.0 hi,  0.1 si,  0.0 st
KiB Mem : 40070540 total,   586648 free, 32520668 used,  6963224 buff/cache
KiB Swap:  2097148 total,     2120 free,  2095028 used.  7169184 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                    
 4062 tomcat    20   0 3039200 568372   4936 S   1.0  1.4   1358:19 java                                                                                                                                       
16372 tomcat    20   0 3290404 699572  23480 S   1.0  1.7   5:11.30 java                                                                                                                                       
16657 tomcat    20   0 3072308 650000  23460 S   1.0  1.6   7:00.49 java                                                                                                                                       
17701 tomcat    20   0 3544120 1.195g  12040 S   0.7  3.1   1:39.45 java                                                                                                                                       
19372 tomcat    20   0 3056204 295384   5860 S   0.7  0.7  41:29.62 java                                                                                                                                       
28021 tomcat    20   0 3774392 1.215g  11832 S   0.7  3.2  58:19.12 java
  • top -Hl pid 顯示應用中的線程運行狀態
[tomcat@idanlu-kaifa-63 ~]$ top -Hp 4062
top - 14:02:19 up 63 days, 21:49,  5 users,  load average: 0.09, 0.14, 0.18
Threads:  60 total,   0 running,  60 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.5 us,  1.3 sy,  0.0 ni, 97.1 id,  0.1 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 40070540 total,   583372 free, 32521324 used,  6965844 buff/cache
KiB Swap:  2097148 total,     2120 free,  2095028 used.  7168508 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                                                                                                                     
 4127 tomcat    20   0 3039200 568372   4936 S  0.3  1.4   4:10.92 java                                                                                                                                        
 4062 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:00.00 java                                                                                                                                        
 4070 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:08.77 java                                                                                                                                        
 4071 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:05.45 java                                                                                                                                        
 4072 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:05.46 java                                                                                                                                        
 4073 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:05.38 java                                                                                                                                        
 4074 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:05.38 java                                                                                                                                        
 4075 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   2:25.77 java                                                                                                                                        
 4076 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:00.02 java                                                                                                                                        
 4077 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:00.03 java                                                                                                                                        
 4078 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:00.00 java                                                                                                                                        
 4079 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:14.96 java                                                                                                                                        
 4080 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:12.26 java                                                                                                                                        
 4081 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:00.00 java                                                                                                                                        
 4082 tomcat    20   0 3039200 568372   4936 S  0.0  1.4  36:12.95 java                                                                                                                                        
 4089 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:42.04 java                                                                                                                                        
 4090 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:00.72 java                                                                                                                                        
 4091 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   1:16.72 java                                                                                                                                        
 4092 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:00.03 java                                                                                                                                        
 4093 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   0:01.84 java                                                                                                                                        
 4094 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   3:57.18 java                                                                                                                                        
 4095 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   3:55.29 java                                                                                                                                        
 4096 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   3:56.72 java                                                                                                                                        
 4097 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   4:04.82 java                                                                                                                                        
 4098 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   3:53.77 java                                                                                                                                        
 4099 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   4:48.47 java                                                                                                                                        
 4100 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   2:38.50 java                                                                                                                                        
 4102 tomcat    20   0 3039200 568372   4936 S  0.0  1.4   1164:36 java
  • 選取運行CPU高,時長長的線程tid。轉換爲16位
[tomcat@idanlu-kaifa-63 ~]$ printf "%x\n" 4102
101f
  • jstack -l pid> 1.txt 打印應用的線程狀況,間隔一段時間,多打印幾回。查找相關 nid
"notify-remoting-reactor-0" prio=10 tid=0x00007f03ed0b3000 nid=0x101f runnable [0x00007f03e0ad1000]
   java.lang.Thread.State: RUNNABLE
	at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
	at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269)
	at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:79)
	at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:87)
	- locked <0x00000000e0f4a698> (a sun.nio.ch.Util$2)
	- locked <0x00000000e0f4a688> (a java.util.Collections$UnmodifiableSet)
	- locked <0x00000000e0f4a570> (a sun.nio.ch.EPollSelectorImpl)
	at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:98)
	at com.taobao.gecko.core.nio.impl.Reactor.select(Reactor.java:334)
	at com.taobao.gecko.core.nio.impl.Reactor.run(Reactor.java:236)
相關文章
相關標籤/搜索