码迷,mamicode.com
首页 > 编程语言 > 详细

Java自带优秀工具

时间:2014-06-20 12:11:31      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:java   调试   performance   内存   

Java自己有很多优秀的调试工具,可以帮助分析系统的漏洞,瓶颈,这里列举几个自己常用的命令:

 jps -l
 查看现有的java进程
jps -l 显示所有正在运行的java进程id
jstack 
查看Java线程
     jstack -l pid; 做thread dump,直接打印在串口
    jstack pid>> ./threaddumps  输出到指定文件分析
jmap
查看Java内存使用情况    
jmap -histo:live pid 对象占用内存排名
jmap -dump:file=memroydumps pid 把heap dump到文件
jhat 

通过查看jmap dump文件分析

jhat ./threaddumps 分析dump文件

d:\cloudlu\workspace\CustomerSecurityManagementSystem\CustomerSecurityManagementWeb>jmap -dump:file=test.map 6860
Dumping heap to D:\cloudlu\workspace\CustomerSecurityManagementSystem\CustomerSecurityManagementWeb\test.map ...
Heap dump file created

d:\cloudlu\workspace\CustomerSecurityManagementSystem\CustomerSecurityManagementWeb>jhat test.map
Reading from test.map...
Dump file created Wed Jun 04 10:49:22 CST 2014
Snapshot read, resolving...
Resolving 1982196 objects...
Chasing references, expect 396 dots.........................................................................................................
............................................................................................................................................
............................................................................................................................................
...........
Eliminating duplicate references............................................................................................................
............................................................................................................................................
............................................................................................................................................
........
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.

http://localhost:7000 查看分析结果

jstat 

查看heap内各个部分的使用量,以及加载类的数量以及GC的相关信息。

jstat -options (查看参数) / jstat -help

jstat -gcutil -t -h 3 6860 200 10
Timestamp         S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT
         2930.6   0.00   0.00  31.53  60.00  91.23  82.55     80    1.622     5    6.644    8.266
         2930.8   0.00   0.00  31.53  60.00  91.23  82.55     80    1.622     5    6.644    8.266
         2931.0   0.00   0.00  31.53  60.00  91.23  82.55     80    1.622     5    6.644    8.266
Timestamp         S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT
         2931.2   0.00   0.00  31.53  60.00  91.23  82.55     80    1.622     5    6.644    8.266
         2931.4   0.00   0.00  31.53  60.00  91.23  82.55     80    1.622     5    6.644    8.266
         2931.6   0.00   0.00  31.53  60.00  91.23  82.55     80    1.622     5    6.644    8.266
Timestamp         S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT
         2931.8   0.00   0.00  31.53  60.00  91.23  82.55     80    1.622     5    6.644    8.266
         2932.0   0.00   0.00  31.53  60.00  91.23  82.55     80    1.622     5    6.644    8.266
         2932.2   0.00   0.00  31.53  60.00  91.23  82.55     80    1.622     5    6.644    8.266
Timestamp         S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT
         2932.4   0.00   0.00  31.53  60.00  91.23  82.55     80    1.622     5    6.644    8.266


jdk自带的hprof

启动应用时带上hprof参数,查看cpu,内存使用情况

java -agentlib:hprof=cpu=times,interval=20,depth=10 -jar start.jar

http://www.cnblogs.com/linhaohong/archive/2012/07/12/2588657.html

Jconsole&Jvisualvm

下回分解

Java自带优秀工具,布布扣,bubuko.com

Java自带优秀工具

标签:java   调试   performance   内存   

原文地址:http://blog.csdn.net/cloud_ll/article/details/28393537

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!