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.
A dump can be taken on demand (using the jmap JDK utility) or when an app fails with OutOfMemoryError (if the JVM was started with the -XX:+HeapDumpOnOutOfMemoryError command line option). A heap dump is a binary file of about the size of your JVM's heap, so it can only be read and analyzed with special tools.
From the main menu, select View | Tool Windows | Profiler. Right-click the necessary process in the Profiler tool window and select CPU and Memory Live Charts. A new tab opens in which you can see the amount of resources the selected process consumes.
To track down a memory leak, you'll need a "heap dump" with a summary of the live objects in a leaky process. To record a dump, first run jps to find the process's PID, then run jmap -dump:live,format=b,file=(dumpfile) (pid) .
The best thing out there is Memory Analyzer (MAT), IntelliJ does not have any bundled heap dump analyzer.
I would like to update the answers above to 2018 and say to use both VisualVM and Eclipse MAT.
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.
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:
Download here: https://www.eclipse.org/mat/downloads.php
And this is how it looks:
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With