jdk工具
12 May ’16
jps :
列出正在运行的虚拟机进程,并显示虚拟机执行主类(main()所在的类)的名称。以及这些进程的本地虚拟机的唯一ID。
jingyu1haodeMacBook-Pro:bin jingyu1hao$ jps -l
78973 com.hqb360.goodscenter.test.WebAppTestServerStarter
71665
79151 com.okhqb.canvas.test.WebAppTestServerStarter
78999 com.okhqb.adminj.test.WebAppTestServerStarter
80909 sun.tools.jps.Jps
jstat : 虚拟机统计信息监视工具
显示本地或远程虚拟机进程中的类装载、内存、垃圾收集、JIT编译等运行数据。
^Cjingyu1haodeMacBook-Pro:bin jingyu1hao$ jstat -gc 78999 1000 20
S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT
30720.0 3584.0 0.0 0.0 572928.0 15071.8 152064.0 72997.8 83968.0 68835.4 43 1.640 8 4.929 6.569
30720.0 3584.0 0.0 0.0 572928.0 15071.8 152064.0 72997.8 83968.0 68835.4 43 1.640 8 4.929 6.569
-gc -gcnew -gcutil -gccapacity -gcold ...
jingyu1haodeMacBook-Pro:bin jingyu1hao$ jstat -gcutil 78999 1000 5
S0 S1 E O P YGC YGCT FGC FGCT GCT
0.00 0.00 2.67 48.00 81.98 43 1.640 8 4.929 6.569
说明 : 两个Survivor区(s0,s1)都是空的 E:新生代使用2.67% O:老年代48.00% P:永久代81.98% 程序运行以来共发生Minor GC (YGC) 43次,总耗时1.640秒发生Full GC 8次,总耗时(FGCT) 4.929秒,所有GC总耗时(GCT) 6.569秒
jinfo:
jingyu1haodeMacBook-Pro:bin jingyu1hao$ jinfo 78999
Attaching to process ID 78999, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.55-b03
Java System Properties:
jmap: java内存映像工具
生成堆转储快照。查询finalize执行队列,java堆和永久代的详细信息,如空间使用率、当前用的是哪种收集器等。
jingyu1haodeMacBook-Pro:~ jingyu1hao$ /usr/bin/jmap -dump:format=b,file=heapdump.bin 78999
78999: Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding
解决方案:加-F参数
jingyu1haodeMacBook-Pro:~ jingyu1hao$ /usr/bin/jmap -F -dump:format=b,file=heapdump.bin 82629
Attaching to process ID 82629, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.55-b03
Dumping heap to heapdump.bin ...
jhat: 虚拟机堆转储快照分析工具 与jmap搭配使用,分析生成的堆转储快照。jhat内置了一个微型的HTTP/HTML服务器,可在浏览器中查看结果。不过一般都会使用Eclipse Memory Analyzer等工具。
jingyu1haodeMacBook-Pro:~ jingyu1hao$ /usr/bin/jhat heapdump.bin
Reading from heapdump.bin...
Dump file created Tue Aug 04 16:23:20 CST 2015
Snapshot read, resolving...
Resolving 867196 objects...
WARNING: Failed to resolve object id 0x162020c98 for field numSockets (signature L)
...
jstack: java堆栈跟踪工具
生成虚拟机当前时刻的线程快照(threaddump或javacore文件)。 当前虚拟机内每一条线程正在执行的方法堆栈的集合,生成线程快照的主要目的是定位线程出现长时间停顿的原因,如线程间死锁、死循环、请求外部资源导致的长时间等待等都是导致线程长时间停顿的常见原因。 通过jstack查看各线程的调用堆栈,可以知道没有响应的线程到底在后台做些什么事,或者是等待着什么资源。
jingyu1haodeMacBook-Pro:~ jingyu1hao$ jstack -l 78999
78999: Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding
jconsole: java监视与管理控制台(可视化)