Introduction to Java Heap dump file analysis tool Jhat

Source: Internet
Author: User
Tags stack trace jconsole

Jhat is the Java Heap analysis tool (Java heap analyzes tools). Become standard after Jdk6u7. Using this command requires some Java development experience, and the official does not provide technical support and customer service for this tool.

Usage:
jhat [Options] Heap-dump-file  

Parameters:

  • options Optional command line parameters, please refer to the options below

  • Heap-dump-fileBinary Java heap dump files to view (Java binary heap dump file). If a dump file contains more than one heap dumps, you can add it after the file name#<number>Specifies which dump to parse, such as:myfile.hprof#3

Example

jmap dumps can be used in the following ways:

jmap-dump:file=dumpfilename.txt,format=b PID  

For example:

C:\users\administrator\desktop>jmap-dump:file=d:/javadump.hprof,format=b 3614Dumping Heap to D:\javaDump.hprof ... Heap dump file created

of These, 3614 is the ID of the Java process that was seen by tasklist, or the task Manager, after this launch of Tomcat, in general, the jmap need to be consistent or compatible with the Java version to successfully export. If you don't know how to use it, enter it directly.jmap, orjmap -hYou can see the prompt message.

Then use the Jhat command when parsing, as follows:

jhat-j-xmx1024m d:/javadump.hprof ... A bunch of information ... Snapshot resolved. Started HTTP Server on port 7000Server are ready.

The -j parameter of Jhat is that the heap memory of the default JVM may not be sufficient to load the entire dump file. Adjust as needed. Follow the prompts to know that the port number is 7000,

You can then access the http://localhost:7000/using your browser to see the relevant information.

Detailed description

The jhat command parses the Java heap dump file and starts a Web server. Then use the browser to view/browse the dump heap. The Jhat command supports pre-designed queries, such as displaying all instances of a class. also supports object Query Language (OQL, Object Language). OQL is a bit like SQL, specifically used to query heap dumps. OQL related help information can be at the bottom of the server page provided by the Jhat command. If you use the default port, the OQL Help information page is: http://localhost:7000/oqlhelp/

Java has heaps of dumps in a variety of ways:

  • Use jmap -dump the option to get the heap dump while the JVM is running. (Refer to the example above) for details see: jmap (1)
  • Usejconsoleoption to obtain a heap dump from the runtime through Hotspotdiagnosticmxbean. Please refer to: Jconsole (1) andHotSpotDiagnosticMXBeanInterface Description: http://docs.oracle.com/javase/8/docs/jre/api/management/extension/com/sun/management/HotSpotDiagnosticMXBean.html.
  • -XX:+HeapDumpOnOutOfMemoryErrorheap dumps are automatically executed when OutOfMemoryError is thrown when an option is specified when the virtual machine starts.
  • Use the hprof command. Please refer to A heap/cpu Profiling tool:http://docs.oracle.com/javase/8/docs/technotes/samples/hprof.html



Options-stack False|true

Close the object assignment call stack trace (tracking object allocation called). If the allocation location information is not available in the heap dump. You must set this flag to false. The default value is true .

-refs False|true

Turn off object reference tracking (tracking of references to objects). The default value is true . By default, the returned pointer is an object that points to another specific object, such as a backlink or input reference (referrers or incoming references), which counts/computes all objects in the heap.

-port Port-number

Set the port number of the Jhat HTTP server. The default value 7000 .

-exclude Exclude-file

Specifies the data member list file that needs to be excluded when querying the object (A-file that lists data, that should is excluded from the reachable objects query). For example, if the file column lists thejava.lang.String.value, when the list of objects that can be reached from a specific object o is calculated, the reference path involvesjava.lang.String.valuewill be excluded.

-baseline Exclude-file

Specifies a base heap dump (baseline heap dump). Objects with the same object ID in the two heap dumps will be marked as not new (marked as not being). Other objects are marked as new. Useful when comparing two different heap dumps.

-debug int

Set the debug level. 0indicates that debugging information is not output. The larger the value, the more verbose debug information is output.

-version

Exit when only the version information is displayed after startup

-H

Displays help information and exits. With-help

-help

Displays help information and exits. With-h

-j< flag >

Because the Jhat command actually launches a JVM to execute, some startup parameters can be passed through -j when the JVM is started. For example, specifies that the -J-Xmx512m maximum heap memory used by the Java Virtual machine running Jhat is one MB. If multiple JVM startup parameters are required, multiple-jxxxxxx are passed in.

Please see also:
    • Jmap (1)
    • Jconsole (1)
    • A HEAP/CPU performance analysis tool

Original link: https://docs.oracle.com/javase/jp/8/technotes/tools/unix/jhat.html

GitHub version: Https://github.com/cncounter/translation/blob/master/tiemao_2014/jhat/jhat.md

Original Date: 2014-05-04

Translation Date: 2014-11-21

Translators: Anchor


Introduction to Java Heap dump file analysis tool Jhat

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.