jdk自带分析工具分析系统故障

1、jstack

Usage:
    jstack [-l] <pid>
        (to connect to running process)
    jstack -F [-m] [-l] <pid>
        (to connect to a hung process)
    jstack [-m] [-l] <executable> <core>
        (to connect to a core file)
    jstack [-m] [-l] [server_id@]<remote server IP or hostname>
        (to connect to a remote debug server)

Options:
    -F  to force a thread dump. Use when jstack <pid> does not respond (process is hung)
    -m  to print both java and native frames (mixed mode)
    -l  long listing. Prints additional information about locks
    -h or -help to print this help message


-F 参数强制导出线程栈,一般在线程被挂起(堵塞)时使用
-m 打印java和本地线程栈帧,native指java调用c/c++本地接口
-l 字面翻译:打印额外信息和锁,实际导出最好加上该选项
-h 列出帮助信息

案例
jstack -F -m -l 1180 > dumpStack.txt

线程栈消息文件分析工具
https://publib.boulder.ibm.com/httpserv/cookbook/Major_Tools-IBM_Thread_and_Monitor_Dump_Analyzer_TMDA.html
过往分析文章
https://blog.csdn.net/ffyyhh995511/article/details/132810006

使用场景
1:java应用占用cpu高
2:排查线程阻塞或挂起
3:查看线程运行情况,例如死锁

2、jmap

jmap
Usage:
    jmap [option] <pid>
        (to connect to running process)
    jmap [option] <executable <core>
        (to connect to a core file)
    jmap [option] [server_id@]<remote server IP or hostname>
        (to connect to remote debug server)

where <option> is one of:
    <none>               to print same info as Solaris pmap
    -heap                to print java heap summary
    -histo[:live]        to print histogram of java object heap; if the "live"
                         suboption is specified, only count live objects
    -clstats             to print class loader statistics
    -finalizerinfo       to print information on objects awaiting finalization
    -dump:<dump-options> to dump java heap in hprof binary format
                         dump-options:
                           live         dump only live objects; if not specified,
                                        all objects in the heap are dumped.
                           format=b     binary format
                           file=<file>  dump heap to <file>
                         Example: jmap -dump:live,format=b,file=heap.bin <pid>
    -F                   force. Use with -dump:<dump-options> <pid> or -histo
                         to force a heap dump or histogram when <pid> does not
                         respond. The "live" suboption is not supported
                         in this mode.
    -h | -help           to print this help message
    -J<flag>             to pass <flag> directly to the runtime system

hprof 文件是 Java 的 内存快照文件(Heap Profile的缩写),格式为xxx.hprof
-histo:live只打印存活的堆对象的柱状图统计信息,现实中不实用也不常用
-finalizerinfo 打印正在等待被回收的对象信息
-F 强制dump出栈信息,不支持live选项
dump在实际中常被用到 

命令案例
jmap -dump:live,format=b,file=heap.bin <pid> 文件后缀是bin
jmap -dump:live,format=b,file=heap.hprof <pid> 文件后缀是hprof

内存堆消息文件分析工具
eclipse mat插件
过往分析文章
todo


使用场景
1:分析 OOM: OutOfMemoryError(堆)内存不足错误
2:JVM设置 -XX:+HeapDumpOnOutOfMemoryError 参数时打印的内容,该参数指应用出现oom自动dump出hprof文件

jvm堆栈资料
https://blog.csdn.net/wang0907/article/details/130544919

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值