标签:java 调试 performance 内存
Java自己有很多优秀的调试工具,可以帮助分析系统的漏洞,瓶颈,这里列举几个自己常用的命令:
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 查看分析结果
查看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 调试 performance 内存
原文地址:http://blog.csdn.net/cloud_ll/article/details/28393537