Linux command
jhat 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Analyze a heap dump
jhat [dump.hprof]
Use a custom HTTP port
jhat -port [8080] [dump.hprof]
Run with more heap
jhat -J-Xmx8g [dump.hprof]
Compare against a baseline dump
jhat -baseline [old.hprof] [new.hprof]
Disable object reference tracking
jhat -stack false -refs false [dump.hprof]
说明
jhat parses a Java heap dump file in HPROF binary format and launches a small HTTP server for browsing the heap. The web UI exposes pre-built queries (instances of a class, reference chains, reachable objects, histograms) and an Object Query Language (OQL) prompt for arbitrary queries over the heap. Heap dumps can be produced by `jmap -dump`, `jcmd <pid> GC.heap_dump`, `jconsole`, or via `-XX:+HeapDumpOnOutOfMemoryError` on a crashing JVM.
参数
- -stack _true|false_
- Track object allocation call stacks (default `true`). Disable to speed up load of large dumps.
- -refs _true|false_
- Track object references (default `true`). Disable to reduce memory use; most reference queries will be unavailable.
- -port _port_
- TCP port for the HTTP server (default 7000).
- -exclude _file_
- Path to a file listing data members to exclude from reachability queries.
- -baseline _file_
- Specify a baseline dump. Objects present in both dumps are marked "not new".
- -debug _int_
- Debug level. `0` = off, `1` = parse HPROF, `2` = parse without starting server.
- -version
- Print version and exit.
- -J_flag_
- Pass _flag_ straight to the JVM running jhat (e.g. `-J-Xmx8g`).
- -help
- Show help.
FAQ
What is the jhat command used for?
jhat parses a Java heap dump file in HPROF binary format and launches a small HTTP server for browsing the heap. The web UI exposes pre-built queries (instances of a class, reference chains, reachable objects, histograms) and an Object Query Language (OQL) prompt for arbitrary queries over the heap. Heap dumps can be produced by `jmap -dump`, `jcmd <pid> GC.heap_dump`, `jconsole`, or via `-XX:+HeapDumpOnOutOfMemoryError` on a crashing JVM.
How do I run a basic jhat example?
Run `jhat [dump.hprof]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -stack _true|false_ do in jhat?
Track object allocation call stacks (default `true`). Disable to speed up load of large dumps.