Can you compare two .hprof files in IntelliJ IDEA?

Answered

I'm trying to track down a memory leak. They way I've done this in the past (a long time ago) was to take two heap snapshots:

  1. After doing some initial setup and a little bit of work
  2. After doing a lot of the same kind of work over and over

Then I'd compare (diff) these two snapshots. Looking at things that only appear in the second snapshot helps remove a lot of noise.

I am now trying to figure out how to do this in IntelliJ IDEA. Some Googling turned up the documentation page, Compare profiler snapshots, which has instructions. Step 1 is no problem: I have opened my two .hprof files, and each appears as a tab in the Profiler window. However, I get stuck on step 2, which says “In the right-hand part of the toolbar, click Compare With Baseline”. I don't know how to do this because:

  • I don't know what toolbar this is referring to.
  • There is nothing labeled “Compare With Baseline” anywhere on my screen that I can see.
  • Even the accompanying screenshots do not show anything labeled “Compare With Baseline”!

I am using IntelliJ IDEA 2023.2.5 (Ultimate Edition) Build #IU-232.10227.8, built on November 8, 2023.

 

0
3 comments

Hello,

Only CPU and memory allocation snapshots can be compared. There is related issue on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-300282. Please follow it for updates.

0

Thanks for your reply,

I can't see that YouTrack issue, unfortunately: the link gives me a 404. It looks like it may be a permissions issue.

What is the difference between a “memory allocation snapshot” and a “heap snapshot”?

Is there a way I can see only live objects that were allocated after a certain point in time? And can I trigger the snapshot and that “checkpoint” from code? I don't want to have to sift through all of the objects created at startup — I just want to see which objects created afterwards so I can focus on the leak.

0

Sorry, seems broken link was inserted. Here is the right one: https://youtrack.jetbrains.com/issue/IDEA-300282

Please take a look at this discussion about differences: https://stackoverflow.com/questions/14029923/heapdump-vs-profiling-memory-in-visual-vm

 

0

Please sign in to leave a comment.