MAT is a Java (heap) memory analyzer produced by Eclipse. We can import heap dumps captured by Android Profiler’s memory performance analyzer into MAT for detailed application memory analysis.

Mac M1 series chips (M1/M1 Pro/M1 Max) use aARCH64 architecture, so pay special attention to the JDK version when installing MAT to avoid application failure due to version mismatch.

My installation environment is as follows:

  • Mac model: MacBook Pro Apple M1 Pro
  • Operating system: macOS Monterey 12.0.1

The following describes the installation process and precautions.

Download MAT

The latest Mac versions do not support the AARCH64 architecture, but Apple does have a built-in Rosetta translator that can run x86_64 architecture applications.

Select the Mac OSX(Mac/Cocoa/ X86_64) version to download the installation file.

2. Install MAT

After downloading the MAT installation file, double-click to install it as prompted.

Once the installation is complete, if you can open the application properly, congratulations, you are lucky, your configuration environment is fine 😂, and you can happily start using MAT for memory analysis.

If, like me, you get an error when you open the JDK, don’t panic. Chances are there is something wrong with the JDK environment.

Configure the Java environment

Conclusion: The latest VERSION of MAT software is required to run on Java 11 or above, and since the Mac is currently only x86_64, you need to make sure that MAT is using the X86_64 JDK.

1. Check the Java version

Enter /usr/libexec/javA_HOME -v on the terminal to view the Java version installed on the local PC.

As you can see, I have 3 Java versions installed on my computer, 17.0.1 (arm64), 11.0.2 (x86_64) and 1.0.8_292 (x86_64).

, the default is/Library/Java/JavaVirtualMachines/JDK – 17.0.1. JDK/Contents/Home, namely 17.0.1 (arm64) version, and I opened the MAT of the error message above, to deserve it.

2. Specify the Java version

Obviously, I’m using the ARM64 version of Java by default, and MAT currently only supports X86_64, so something went wrong.

For now, I just need to change the Java version MAT uses to x86_64.

2.1 Downloading the Java Version


If you do not have Java 11 (x86_64) or later JDK installed on your computer, you can download the eligible Mac_O version from the JDK website. It was only at 17 GA (Build 17+35) that the distinction between AARCH64 and x86 architecture began.

I downloaded the 11.0.2 (Build 11.0.2+9) version.

2.2 Configuring the Java Version


There are two ways to change the Java version.

First, you can configure the JAVA_HOME environment variable to specify the Java version used by the system by default, which takes effect globally.

Second, you can modify the MAT application’s configuration file to specify the version of Java that MAT uses.

I recommend the second method. This method does not change the default configuration of the entire system for one application, which may cause errors in other applications using the Java environment.

2.3 Modifying MAT Configurations


  1. Go to Access -> Apps to find MAT, right-click -> Show package Contents -> Contents -> info.plist.

  1. Open info.plist and find the location of the comment below. Add a script to specify the Java path that MAT uses.
<! -- To use a specific Java version (instead of the default) uncomment the following option and edit it to add a VM. Installed VMs can be found via $/usr/libexec/java_home -V <string>-vm</string><string>/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin/java</string> --> <! -- Note that the path must be complete, --> <string> -- vm</string> < string > / Users/seven/Library/Java/JavaVirtualMachines/JDK - 11.0.2 / Contents/Home/bin/Java < / string >Copy the code
  1. Save the configuration changes and restart the MAT. Import the file and start analyzing!