Java Heap dump file analysis tool Jhat profile __java

Source: Internet
Author: User
Tags stack trace jconsole

Jhat is the Java Heap analysis tool (Java heap analyzes Tool). Become standard after the 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, refer to the options below

Heap-dump-file The binary Java heap dump file to view (Java binary heap dump file). If a dump file contains multiple copies of heap dumps, you can specify which dump to resolve by adding #<number> after the file name, 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 3614
Dumping Heap to D:\
javadump.hprof ... Heap dump file created

Of these, 3614 is after the start of Tomcat, through Tasklist, or task Manager to see the Java Process ID, in general, Jmap needs and Java version is consistent or compatible, in order to successfully export. If you don't know how to use it, enter jmap directly or jmap-h to see the hint.

The Jhat command is then used for analysis, as follows:

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

The Jhat-j parameter is because the default JVM's heap memory may not be sufficient to load the entire dump file. Make adjustments as needed. As prompted to know that the port number is 7000,

You can then use the browser to access the Http://localhost:7000/to see the relevant information. Detailed Description

The jhat command resolves the Java heap dump file and starts a Web server. Then use the browser to view/Browse the dump out of the heap. The jhat command supports predesigned queries, such as displaying all instances of a class. Object Query Language (OQL, Object Language) is also supported. OQL is a bit like SQL, designed 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/

There are several ways Java can heap dumps: using the jmap-dump option to get heap dump when the JVM is running. (Refer to the example above) for details see: Jmap (1) Use the Jconsole option to obtain a heap dump from the runtime using the Hotspotdiagnosticmxbean. Please refer to: Jconsole (1) and Hotspotdiagnosticmxbean interface Description: http://docs.oracle.com/javase/8/docs/jre/api/management/ Extension/com/sun/management/hotspotdiagnosticmxbean.html.
When the-XX:+HEAPDUMPONOUTOFMEMORYERROR option is specified when the virtual machine is started, the heap dump is automatically performed when the OutOfMemoryError is thrown. 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

Closes the object assignment call stack trace (tracking object allocation calls stack). 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

Closes the object reference trace (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 reverse link or an input reference (referrers or incoming references) that counts/calculates all the objects in the heap. -port Port-number

Sets the port number of the Jhat HTTP server. The default value is 7000. -exclude Exclude-file

Specifies the data member list file to exclude when querying for an object (a file that lists data membership that should is excluded from the reachable objects query). For example, if the file column lists Java.lang.String.value, the reference path involving Java.lang.String.value is excluded when you compute the list of objects that are available from the object o of a particular object. -baseline Exclude-file

Specifies a base heap dump (baseline heap dump). Objects that have the same object ID in the two heap dumps are marked as not new (marked as not being a). Other objects are marked as new. Useful when comparing two different heap dumps. -debug int

Set the debug level. 0 indicates that debugging information is not output. Larger values indicate more detailed debug information for the output. -version

Exit- H If only version information is displayed after startup

Displays help information and exits. -help with-help

Displays help information and exits. Same-H -j< flag >

Because the Jhat command actually initiates a JVM to execute,-J can pass some startup parameters when the JVM is started. For example,-j-xmx512m specifies that the maximum heap memory used by the Java Virtual machine running Jhat is MB. If you need to use multiple JVM startup parameters, pass in multiple-jxxxxxx. See also: jmap (1) jconsole (1) A HEAP/CPU profiling 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

Translation staff: Anchor


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.