jhat - Java Heap Analysis Tool

This section describes the Java heap analysis tool 'jhat' command and its options. 'jhat' can be used browse a Java heap dump file through a Web interface.

Warning: "jhat" has been discontinued since JDK 9. But if you still have JDK 1.8 installed, you can continue to use it to browser heap dump files generated by JDK 9 to JDK 12.

What Is "jhat"? - "jhat" is a Java heap analysis tool or heap dump file browser: Parses a Java heap dump file and launches a Web server. "jhat" enables you to browse heap dump files using your favorite Web browser. "jhat" supports pre-designed queries (such as 'show all instances of a known class "Foo"') as well as OQL (Object Query Language) - a SQL-like query language to query heap dumps. Help on OQL is available from the OQL help page shown by "jhat". With the default port, OQL help is available at http://localhost:7000/oqlhelp/

But the "jmap" tool included in the Windows version of JDK only supports functions to print histogram of Java object heap and generate a heap dump of a given JVM process:

herong> \Progra~1\java\jdk1.8.0\bin\jhat -help

Usage: jhat [-stack <bool>] [-refs <bool>] [-port <port>]
   [-baseline <file>] [-debug <int>] [-version] [-h|-help] <file>

   -stack false     Turn off tracking object allocation call stack.
   -refs false      Turn off tracking of references to objects
   -port <port>     Set the port for the HTTP server. Default is 7000.
   -exclude <file>  Specify a file that lists data members that should
                    be excluded from the reachableFrom query.
   -baseline <file> Specify a baseline object dump.  Objects in
                    both heap dumps with the same ID and same class
                    will be marked as not being "new".
   -debug <int>     Set debug level.
                    0:  No debug output
                    1:  Debug hprof file parsing
                    2:  Debug hprof file parsing, no server
   -version         Report version number
   -h|-help         Print this help and exit
   <file>           The file to read

For a dump file that contains multiple heap dumps,
you may specify which dump in the file
by appending "#<number>" to the file name, i.e. "foo.hprof#3".

All boolean options default to "true"

Table of Contents

 About This Book

 Java Tools Terminology

 Java Tools Included in JDK

 javac - The Java Program Compiler

 java - The Java Program Launcher

 jar - The JAR File Tool

 jlink - The JRE Linker

 jmod - The JMOD File Tool

 jimage - The JIMAGE File Tool

 jpackage - Binary Package Builder

 javadoc - The Java Document Generator

 jdeps - The Java Class Dependency Analyzer

 jdeprscan - The Java Deprecated API Scanner

 jdb - The Java Debugger

 jcmd - The JVM Diagnostic Tool

 jconsole - Java Monitoring and Management Console

 jstat - JVM Statistics Monitoring Tool

JVM Troubleshooting Tools

 JVM Troubleshooting Tools in JDK

 jinfo - VM Option Value Checker

 jinfo - Changing HotSpot VM Option

 jstack - Stack Tracer to Generate Thread Dump

 What Is a Thread Dump?

 Java Thread Deadlock Demo Program

 jstack - Detecting Java Thread Deadlocks

 jmap - JVM Heap Dump Tool

 Printing Histogram of Java Object Heap

 jmap - Generating Heap Dump File

jhat - Java Heap Analysis Tool

 jhat - Starting Web Server on a Heap Dump File

 Listing Instance Counts of All Classes

 Browsing Object Instance Values

 Object Query Language (OQL)

 Searching for Instances with OQL Statements

 jhsdb - The Java HotSpot Debugger

 jvisualvm (Java VisualVM) - JVM Visual Tool

 jmc - Java Mission Control

 javap - The Java Class File Disassembler

 keytool - Public Key Certificate Tool

 jarsigner - JAR File Signer

 jshell - Java Language Shell

 jrunscript - Script Code Shell

 Miscellaneous Tools

 native2ascii - Native-to-ASCII Encoding Converter

 JAB (Java Access Bridge) for Windows

 Archived Tutorials

 References

 Full Version in PDF/EPUB