简体   繁体   中英

How can I analyze a heap dump in IntelliJ? (memory leak)

I have generated a heap dump from my java application which has been running for some days with the jmap tool -> this results in a large binary heap dump file.

How can I perform memory analysis of this heap dump within IntellIJ IDEA?

I know that there are tools for Eclipse and Netbeans but I would rather use IDEA if possible.

The basic results of the analysis would tell me the number of instances of each object in memory, per-class, to allow me to be able to start debugging memory leaks.

最好的东西是Memory Analyzer (MAT) ,IntelliJ 没有任何捆绑的堆转储分析器。

I would like to update the answers above to 2018 and say to use both VisualVM and Eclipse MAT.

How to use:

VisualVM is used for live monitoring and dump heap. You can also analyze the heap dumps there with great power, however MAT have more capabilities (such as automatic analysis to find leaks) and therefore, I read the VisualVM dump output (.hprof file) into MAT.



Get VisualVM:

Download VisualVM here: https://visualvm.github.io/

You also need to download the plugin for Intellij: 在此处输入图片说明

Then you'll see in intellij another 2 new orange icons: 在此处输入图片说明

Once you run your app with an orange one, in VisualVM you'll see your process on the left, and data on the right. Sit some time and learn this tool, it is very powerful: 在此处输入图片说明



Get Eclipse's Memory Analysis Tool (MAT) as a standalone:

Download here: https://www.eclipse.org/mat/downloads.php

And this is how it looks: 在此处输入图片说明 在此处输入图片说明

Hope it helps!

You can also use VisualVM Launcher to launch VisualVM from within IDEA. https://plugins.jetbrains.com/plugin/7115?pr=idea I personally find this more convenient.

在插件存储库中还存在一个“JVM 调试器内存视图”,这可能很有用。

You can just run "Java VisualVM" which is located at jdk/bin/jvisualvm.exe

This will open a GUI, use the "File" menu -> "Load..." then choose your *.hprof file

That's it, you're done!

VisualVM plugin for Intellij Idea

在此处输入图片说明

You can install the JVisualVM plugin from here: https://plugins.jetbrains.com/plugin/3749?pr=

This will allow you to analyse the dump within the plugin.

Start from IntelliJ IDEA 2021.2<\/strong> , there is a feature called Open an external profiling report<\/a> . The UI for the viewer like below:

  1. <\/li>
  2. <\/li>
  3. <\/li><\/ol>"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM