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.

2 Responses to Running Eclipse MAT on macOS

  1. Sandeep D says:

    Thank you for the write up. It saved the day for me.

  2. Philip says:

    Thanks.
    My MAT version is :MemoryAnalyzer-1.15.0.20231206-macosx.cocoa.aarch64.dmg, and the MemoryAnalyzer.ini is at /Applications/MemoryAnalyzer.app/Contents/Eclipse/

Leave a comment