Running Eclipse MAT on macOS

If you try to run Eclipse Memory Analyzer (MAT) out of the box on macOS, you’ll likely get an error that you need version 11 or above of Java, even if you have version 11 installed (say, with SDKMAN!).

You need to tell Eclipse MAT where to find this version of Java. Don’t edit the info.plist file, because then you’ll get an invalid code signature error.

Instead, you want to edit the /Applications/mat.app/Contents/Eclipse/MemoryAnalyzer.ini file. I added the following two lines to the top of my file:

-vm
/Users/lhochstein/.sdkman/candidates/java/current/bin

Worked like a charm. (Note that adding these to the bottom of the file didn’t work).

I also had to increase the size of the heap. I bumped it to 12GB, by editing the appropriate line in MemoryAnalyzer.ini to:

-Xmx12G

Final note: you may want to show Unreachable objects. I’m just going to copy-paste from this Stack Overflow answer.

  1. Close the snapshot
  2. Select the heap dump using Window > Heap Dump History right-click, Delete Index Files
  3. Select ‘Keep unreachable objects’ using Window > Preferences > Memory Analyzer
  4. Reopen the heap dump, which will reparse the heap dump.
  5. Select the Java Basics > GC Roots query.
  6. Select the ‘Unreachable Objects’ row.
  7. Run the ‘Show Retained Set’ query on that row.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s