Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to analyze java heap hprof files under mac platform

Shulou Source: shulou.com Published: 2022-05-31 11:02:47 09月17日 Update

This article mainly explains "how to analyze java heap hprof files under the mac platform". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to analyze java heap hprof files under the mac platform".

Use the jhat command that comes with jdk

How to print stack information to a hprof file

Run the program to add VM parameters:

-XX:+HeapDumpOnOutOfMemoryError # will print that when a memory overflow exception occurs, Dump will quickly find the current memory heap for analysis

Step 1:

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

Jhat java_pid73912.hprof

Executing 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.

When it is seen that Server is ready. After that, it can be accessed through the ip + port address browser. I am local, so it is localhost:7000.

Clicking Show instance counts for all classes (including platform) will display the information of the class that contains the platform.

Clicking Show instance counts for all classes (excluding platform) will display information about all classes that do not include the platform.

You can see that the class that takes up the most space here is class com.geniu.book.deepinJVM.chapter2.TestHeapOOM$OOMObject, which has more than 800,000 instances.

In this way, we can analyze the objects in memory and analyze the abnormal situation when the memory overflow occurs.

Other proposed options:

1) use the idea plug-in JProfiler

2) minidump_stackwalk tool, which can read dump files

Thank you for your reading, the above is the content of "how to analyze java heap hprof files under the mac platform". After the study of this article, I believe you have a deeper understanding of how to analyze java heap hprof files under the mac platform. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Files analysis platform memory commands information situations learning content parameters can be passed through name address stack instance object that is tools suggestions ideas Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info OPPO Reno Apple Shulou Information Microsoft