Introduction to Java Heap dump file analysis tool jhat, heapjhat

Source: Internet
Author: User
Tags jconsole

Introduction to Java Heap dump file analysis tool jhat, heapjhat

Jhat is a Java heap Analyzes Tool ). after JDK6u7, it becomes standard. this command requires some Java development experience. The official website does not provide technical support and customer service for this tool.

Usage:
jhat [ options ] heap-dump-file

Parameters:

  • Options: optional command line parameters. See the following Options

  • Heap-dump-file: the binary Java heap dump file to be viewed ). If a dump file contains multiple heap dumps, you can add#<number>Specifies which dump to parse, such:myfile.hprof#3

Example

The jmap dump can be implemented as follows:

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

Among them, 3614 is the ID of the java Process viewed through tasklist or task manager after Tomcat is started. Generally, jmap needs to be consistent or compatible with the java version to be exported successfully. if you do not know how to use it, enterjmap, Orjmap -hThe prompt is displayed.

Then use the jhat command for analysis, as shown below:

Jhat-J-Xmx1024m D:/javaDump. hprof... a bunch of information... Snapshot resolved. Started HTTP server on port 7000 Server is ready.

The jhat-J parameter is because the default JVM heap memory may not be enough to load the entire dump file. adjust the parameter as needed. The port number is 7000 as prompted,

Then, access http: // localhost: 7000/in the browser to view 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/view the heap dumped by dump. the jhat command supports pre-designed queries, such as displaying all instances of a class. OQL and Object Query Language are also supported ). OQL is similar to SQL and used to query heap dump. OQL-related help information can be found at the bottom of the server page provided by the jhat command. If the default port is used, the OQL help page is http: // localhost: 7000/oqlhelp/

Java generates multiple methods of heap dumping:

  • Usejmap -dumpYou can obtain heap dump when JVM is running (refer to the example above). For more information, see jmap (1)
  • UsejconsoleOption: Use HotSpotDiagnosticMXBean to get a heap dump from the runtime. See jconsole (1) andHotSpotDiagnosticMXBeanThe Interface Description of: http://docs.oracle.com/javase/8/docs/jre/api/management/extension/com/sun/management/HotSpotDiagnosticMXBean.html.
  • If you specify-XX:+HeapDumpOnOutOfMemoryErrorIf an OutOfMemoryError is thrown, the heap dump is automatically executed.
  • UsehprofCommand. See A Heap/CPU Profiling Tool: http://docs.oracle.com/javase/8/docs/technotes/samples/hprof.html



Options-stack false | true

Close the tracking object allocation call stack ). If the allocation location information is unavailable in the heap dump, you must set this flag to false. The default value istrue.

-Refs false | true

Disable object reference tracking (tracking of references to objects ). The default value istrueBy default, the returned pointer is an object pointing to another specific object, such as a reverse link or input reference (referrers or incoming references). All objects in the heap are counted/calculated.

-Port-number

Set the port number of the jhat HTTP server. Default Value7000.

-Exclude-file

Specifies the data member list file to be excluded during object query (a file that lists data members that shocould be excluded from the reachable objects query ). For example, if the file column listsjava.lang.String.valueThe reference path involvesjava.lang.String.valueWill be excluded.

-Baseline exclude-file

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

-Debug int

Set the debug level.0Indicates that no debugging information is output. A greater value indicates a more detailed debug information.

-Version

After the instance is started, it only displays version information and exits.

-H

Displays help information and exits.-help

-Help

Displays help information and exits.-h

-J <flag>

Because the jhat Command actually starts a JVM for execution, you can use-J to input some startup parameters when starting the JVM. For example,-J-Xmx512mThe maximum heap memory used by the Java virtual machine running jhat is 512 MB. If multiple JVM startup parameters are required, multiple-Jxxxxxx are input.

For more information, see:
  • Jmap (1)
  • Jconsole (1)
  • One Heap/CPU Performance Analysis Tool

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

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

Original Article Date:

Translation Date:

Translated by: Tie


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.