jps JVM Process Status Tool,显示指定系统内所有的HotSpot虚拟机进程
jps -l 输出主类全名,如果是JAR包,则输出JAR路径
jps -v 输出虚拟机进程启动时JVM参数
jstat JVM Statistics Monitoring Tool,用于收集HotSpot虚拟机各方面的运行数据
jstat -gcutil 进程号 [刷新毫秒数]
S0 S1 E O P YGC YGCT FGC FGCT GCT
0.00 0.00 3.23 8.14 49.97 6 1.089 3 2.630 3.719
S0和S1:新生代2个survivor区 使用百分比
E:是新生代的伊甸区 使用百分比
O:老年代 使用百分比
P:永久代 使用百分比
YGC:minor GC,发生在新生代的GC次数
YGCT:新生代GC总耗时
FGC:major GC,发生在老年代的GC次数
FGCT:老年代GC总耗时
GCT:总GC耗时
jinfo Configuration Info for Java,显示虚拟机配置信息
jinfo 进程号
jmap Memory Map for Java,生成虚拟机的内存转储快照(heapdump文件)
jmap -dump:format=b,file=/tmp/mydump.bin 进程号
输出
Dumping heap to /tmp/mydump.bin ...
Heap dump file created
jhat JVM Heap Dump Browser,用于分析headdump文件,他会建立一个HTTP/HTML服务器,让用户可以在浏览器上查看分析结果
jhat mydump.bin
输出的信息如下
Reading from mydump.bin...
Dump file created Fri Jan 10 15:51:28 CST 2014
Snapshot read, resolving...
Resolving 2810470 objects...
Chasing references, expect 562 dots..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Eliminating duplicate references..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.
重点要分析
Show heap histogram
jstack Stack Trace for Java,显示虚拟机的线程快照
jstack -l 进程号 除堆栈外,显示关于锁的附加信息
输出信息
2014-01-10 16:00:23
Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.45-b01 mixed mode):
"Worker-16" prio=10 tid=0x00007f643815e800 nid=0x1cdb in Object.wait() [0x00007f63f2765000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x0000000785fb3280> (a org.eclipse.core.internal.jobs.WorkerPool)
at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:188)
- locked <0x0000000785fb3280> (a org.eclipse.core.internal.jobs.WorkerPool)
at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:220)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:50)
Locked ownable synchronizers:
- None
"Worker-15" prio=10 tid=0x00007f643883f800 nid=0x1c70 in Object.wait() [0x00007f63f2967000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x0000000785fb3280> (a org.eclipse.core.internal.jobs.WorkerPool)
at org.eclipse.core.internal.jobs.WorkerPool.sleep(WorkerPool.java:188)
- locked <0x0000000785fb3280> (a org.eclipse.core.internal.jobs.WorkerPool)
at org.eclipse.core.internal.jobs.WorkerPool.startJob(WorkerPool.java:220)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:50)
Locked ownable synchronizers:
- None
"Attach Listener" daemon prio=10 tid=0x00007f6414003000 nid=0x1c36 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE