Home > Java > javaTutorial > body text

How to analyze Java heap dump (hprof) file on Mac platform?

PHPz
Release: 2023-04-20 23:07:07
forward
2863 people have browsed it

Use jhat command that comes with jdk

How to print stack information to hprof file

Run the program to increase VM parameters:

-XX:+HeapDumpOnOutOfMemoryError # 会打印出现内存溢出异常时,Dump出当前内存堆转存快找以便分析
Copy after login

Step 1:

In the command line interface, execute the following command, where java_pid73912.hprof is the file name

jhat java_pid73912.hprof
Copy after login

The execution of the command will output

Reading from java_pid73912.hprof...Dump file created Thu Apr 08 22:18:08 CST 2021Snapshot read, resolving...Resolving 818890 objects...Chasing references, expect 163 dots...................................................................................................................................................................Eliminating duplicate references...................................................................................................................................................................Snapshot resolved.Started HTTP server on port 7000Server is ready.
Copy after login

When you see that Server is ready., you can access it through the ip port address browser. I am local here, so it is localhost:7000

How to analyze Java heap dump (hprof) file on Mac platform?

ClickShow instance counts for all classes (including platform)Will display information about classes including platform

How to analyze Java heap dump (hprof) file on Mac platform?

ClickShow instance counts for all classes (excluding platform)will display information about all classes excluding platform

How to analyze Java heap dump (hprof) file on Mac platform?

You can view it The class that takes up the most space here is class com.geniu.book.deepinJVM.chapter2.TestHeapOOM$OOMObject with more than 800,000 instances.

In this way, you can analyze the object status in the memory and analyze abnormal situations when a memory overflow occurs.

Other suggestions:

1) Use the idea plug-in JProfiler

2) The minidump_stackwalk tool can read dump files

The above is the detailed content of How to analyze Java heap dump (hprof) file on Mac platform?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template