前言
jmap
Google了半天发现其实最好的方法是查看帮助信息,输入命令 jmap -h 就有如下因为英文说明
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 #jvm 参数
jps
# 显示类全名
$ jps -l
# 显示虚拟机参数
$ jps -v
jstat
实时查看jvm的资源情况,比如内存,gc情况
感谢博客 https://www.jianshu.com/p/845924a1b8f2.
# 实时刷新gc情况
$ jstat -gc <pid> <interval> <count>
jinfo
全称是 java configuration info ,实时的查看 jvm的参数,和修改部分可以实时修改的参数
感谢博客 https://www.jianshu.com/p/c321d0808a1b.
#Linux环境查看可动态修改的参数
$ java -XX:+PrintFlagsInitial | grep manageable
#Window环境查看可动态修改的参数
#java -XX:+PrintFlagsInitial | findstr manageable
jhat
Java Heap Analyse Tool 这个工具是用来分析dump文件的,如果可以得到dump文件,也不会用这个工具
jstack
输出threaddump
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) 连接dump的文件
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
以外收获
linux 查看java线程数
感谢博客https://blog.csdn.net/qq_35687098/article/details/83781341.
# Threads 就是线程数
$ top -Hp <pid>
# 直接统计行数
$ ps huH p 98966 | wc -l
转16进制
# 转16进制,查线程id的时候很有用
$ printf "%x\n" 67163
jconsole
感谢博客 https://www.cnblogs.com/kongzhongqijing/articles/3621441.html.这个博客应该是用软件翻译官方文档而来,但是还是比较细,勉强看得懂
通俗易懂理解 jmx,Mbean https://blog.csdn.net/xiezhenxiang/article/details/5447659
jconsole 的类容主要有如下几部分:
概述 - JVM概述和一些监控变量的信息
内存 - 内存的使用信息(很有用)
线程 - 线程的使用信息
类 - 加载java类的信息
VM - JVM摘要
MBeans - 所有MBeans的信息
jvisualvm
这个只是简单的看了下,完全可以用下面这个工具替代
memory analyzer
感谢博客https://www.jianshu.com/p/759e02c1feee
这个工具还是比较强大的,英文不好,就只好依赖大牛的博客了