天天看点

Java性能监控工具(jstack)

介绍

jstack用来查看Java进程的堆栈信息

常用参数

Java性能监控工具(jstack)

首先查看oracle官网的介绍

Java性能监控工具(jstack)
pid不做详细介绍
executable

描述:Java executable from which the core dump was produced.

中文意思:Java程序核心dump生成

core

描述:core file for which the stack trace is to be printed.

中文意思:打印堆栈跟踪的核心文件

remote-hostname-or-IP不做详细介绍
server-id不做详细介绍

需要特别注意的是在官方描述中有这样一句话: If the given process is running on a 64-bit VM, you may need to specify the -J-d64 option.意思就是如果程序运行在64位虚拟机上需要添加-J-d64

例:jstack -J-d64 -m pid

Options介绍:

-F

描述:to force a thread dump. Use when jstack does not respond (process is hung)

个人理解:当使用jstack 没有相应信息的时候强制打印线程栈信息

-l

描述:Long listing. Prints additional information about locks such as list of owned java.util.concurrent ownable synchronizers.

个人理解:打印关于锁的额外信息java.util.concurrent的ownable synchronizers列表

-m

描述:prints mixed mode (both Java and native C/C++ frames) stack trace.

个人理解:打印混合模式(Java和本地C/C++框架)堆栈信息

个人使用总结:

使用jstack -F -l 查看是否提示有死锁

Java性能监控工具(jstack)

如果出现死锁再根据dump信息做进一步分析。