jhat 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

jhat 命令安装:


-bash: jhat: command not found

#Debian
apt-get install openjdk-7-dbg

#Ubuntu
apt-get install openjdk-7-dbg

#Arch Linux
pacman -S jdk8-openjdk

#Kali Linux
apt-get install openjdk-8-jdk-headless

#Fedora
dnf install java

#Raspbian
apt-get install openjdk-8-jdk

jhat 命令补充说明:


jhat 是分析 Java Heap(堆)。此命令是实验性的。该 jhat 命令解析 Java 堆转储文件并启动 Web 服务器。该 jhat 命令使您可以使用喜爱的 Web 浏览器浏览堆转储。该 jhat 命令支持预先设计的查询,例如显示已知类的所有实例 MyClass 以及对象查询语言 OQLOQLSQL 相似,除了查询堆转储。可从该 jhat 命令显示的 OQL 帮助页面获得有关 OQL 的帮助。

使用默认端口,可以从 http://localhost:7000/oqlhelp/ 获得 OQL 帮助。

jhat 命令语法:


jhat [ options ] heap-dump-file

jhat 命令选项:


-stack false|true
Turns off tracking object allocation call stack. If allocation site information is not available in the heap dump, then you have to set this flag to false. The default is true.

-refs false|true
Turns off tracking of references to objects. Default is true. By default, back pointers, which are objects that point to a specified object such as referrers or incoming references, are calculated for all objects in the heap.

-port port-number
Sets the port for the jhat HTTP server. Default is 7000.

-exclude exclude-file
Specifies a file that lists data members that should be excluded from the reachable objects query. For example, if the file lists java.lang.String.value, then, then whenever the list of objects that are reachable from a specific object o are calculated, reference paths that involve java.lang.String.value field are not considered.

-baseline exclude-file
Specifies a baseline heap dump. Objects in both heap dumps with the same object ID are marked as not being new. Other objects are marked as new. This is useful for comparing two different heap dumps.

-debug int
Sets the debug level for this tool. A level of 0 means no debug output. Set higher values for more verbose modes.

-version
Reports the release number and exits

-h
Displays a help message and exits.

-help
Displays a help message and exits.

-Jflag
Passes flag to the Java Virtual Machine on which the jhat command is running. For example, -J-Xmx512m to use a maximum heap size of 512 MB.

jhat 命令实例:


分析堆转储(从 jmap),通过端口 7000 上的 http 查看:

jhat dump_file.bin

分析堆转储,为 http 服务器指定备用端口:

jhat -p port dump_file.bin

分析一个转储,让 jhat 使用多达 8GB 的 RAM(建议使用 2-4 倍转储大小):

jhat -J-mx8G dump_file.bin

jhat 命令扩展阅读:




jhat 命令评论