jhat(1)
πΈ NAME πΈ
jhat β bestie, this one analyzes the Java heap π and heads up: this command is experimental and unsupported, so it's giving "use at your own risk, no cap" energy π
β¨ SYNOPSIS β¨
jhat [ options ] heap-dump-file
optionsβ the command-line options, obvi. Peep the OPTIONS section below πheap-dump-fileβ the Java binary heap dump file you wanna browse, periodt. If your dump file has multiple heap dumps stuffed in it, you can say which one you want by slapping#<number>on the end of the file name, likemyfile.hprof#3π
π¦ DESCRIPTION π¦
okay so jhat parses a Java heap dump file and then starts a web server β¨ Which means yes bestie, you get to browse your heap dumps with your favorite web browser, no fancy tooling required, we love an accessible queen π
It supports predesigned queries β like showing all instances of a known class, e.g. MyClass β plus Object Query Language (OQL). OQL is basically SQL's cousin, except it queries heap dumps instead of databases, iykyk π§ Help on OQL lives right there on the OQL help page that jhat shows you. With the default port, that OQL help is at http://localhost:7000/oqlhelp/ π
π So how do you even make a Java heap dump? π
There are several ways, bestie, and I'm listing all of them π
- Use the
jmap -dumpoption to snag a heap dump at runtime. Seejmap(1)π - Use the
jconsoleoption to get a heap dump throughHotSpotDiagnosticMXBeanat runtime. Seejconsole(1)and theHotSpotDiagnosticMXBeaninterface description athttp://docs.oracle.com/javase/8/docs/jre/api/management/extension/com/sun/management/HotSpotDiagnosticMXBean.html⨠- A heap dump gets generated when an
OutOfMemoryErroris thrown, if you specify the-XX:+HeapDumpOnOutOfMemoryErrorJava Virtual Machine (JVM) option π (iconic chaotic energy tbh) - Use the
hprofcommand. See the HPROF: A Heap/CPU Profiling Tool athttp://docs.oracle.com/javase/8/docs/technotes/samples/hprof.htmlπ
π OPTIONS π
-stack false|trueβ turns off tracking of the object allocation call stack. If the allocation site info isn't available in the heap dump, then you have to set this flag tofalse, no wiggle room bestie. Default istrueπ«Ά-refs false|trueβ turns off tracking of references to objects. Default istrue. By default, back pointers (those are objects pointing at a specified object β think referrers, aka incoming references) get calculated for every single object in the heap π-port port-numberβ sets the port for thejhatHTTP server. Default is7000β¨-exclude exclude-fileβ points at a file that lists data members that should be excluded from the reachable objects query. Like, say the file listsjava.lang.String.valueβ then, then whenever the list of objects reachable from a specific objectogets calculated, reference paths that involve thejava.lang.String.valuefield are just... not considered π-baseline exclude-fileβ specifies a baseline heap dump. Objects in both heap dumps that share the same object ID get marked as not new. Everything else gets marked as new. Super handy for comparing two different heap dumps, chef's kiss π-debug intβ sets the debug level for this tool. A level of0means no debug output at all. Crank it higher for more verbose modes π-versionβ reports the release number and exits, short and sweet β-hβDsiplaysa help message and exits π (yes it says "Dsiplays", I am simply reporting the vibes as they are)-helpβ displays a help message and exits πΈ-Jflagβ passes flag to the Java Virtual Machine thatjhatis running on. For example,-J-Xmx512mto use a maximum heap size of 512 MB π
π SEE ALSO π
jmap(1)jconsole(1)- HPROF: A Heap/CPU Profiling Tool at
http://docs.oracle.com/javase/8/docs/technotes/samples/hprof.html
okay that's the whole page bestie, you're officially a heap-dump-browsing legend π This one's straight outta JDK 8, dated 21 November 2013 β a true vintage icon, slay πβ¨π
π¦ where this page comes from
- arch rolling: jdk8-openjdk 8.504.u01-1 Β· LicenseRef-Java
- Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms