jhat
Analyze Java heap dumps
TLDR
Analyze a heap dump (from jmap), view via HTTP on port 7000
Analyze a heap dump, specifying an alternate port for the HTTP server
Analyze a dump letting jhat use up to 8 GB RAM (2-4x dump size recommended)
SYNOPSIS
jhat [option]... heap-dump-file
PARAMETERS
-baseline exclude
Compare heap dump against baseline file, excluding dead objects if exclude specified.
-debug n
Set debug output level to integer n (0-2).
-Jflag
Pass JVM arguments, e.g., -J-Xmx1g for heap size or -J-Djhatserve.port=9090 for custom port.
-parse-only
Parse heap dump only; do not launch web server.
-version
Display version information and exit.
-h or -help
Print usage help.
DESCRIPTION
JHAT (Java Heap Analysis Tool) is a command-line utility bundled with the JDK for analyzing Java heap dump files. It parses the heap dump (typically generated by jmap or OutOfMemoryError) and starts an embedded HTTP server, enabling interactive browsing via a web browser at http://localhost:7000 by default.
The web interface offers queries like 'All Classes', 'All Objects', 'Object Query Language (OQL)', and heap histogram views. Users can inspect instance details, references, and roots, aiding in memory leak detection and performance tuning.
Usage is straightforward: jhat dump.hprof launches the server. It's lightweight for small-to-medium heaps but can be memory-intensive for large dumps. Supports HPROF binary format. Ideal for quick analysis without external tools, though modern alternatives like Eclipse MAT provide richer features.
JHAT excels in portability across platforms, requiring only JDK installation. Debug levels and JVM tuning enhance usability for advanced diagnostics.
CAVEATS
Memory-intensive for large heaps (>1GB); basic UI lacks advanced filtering. Not recommended for production-scale analysis; use Eclipse MAT instead. Default port 7000 may conflict.
WEB QUERIES
Key features: All Classes, Heap Histogram, OQL Console for custom queries like select * from java.lang.String.
EXAMPLE
jhat -J-Xmx2g mydump.hprof
Open browser to http://localhost:7000/oqlhelp/ for OQL docs.
HISTORY
Introduced in JDK 6 (2006) as part of diagnostic suite. Maintained through JDK 21; deprecated in favor of external tools like VisualVM or MAT since JDK 8.


