The other day I upgraded my Mac laptop to Big Sur and suddenly eclipse Memory Analyzer tool (MAT) stopped working with an error message “Failed to create the Java Virtual Machine.”, similar to following error dialog.

error from eclipse MAT

error from eclipse MAT

Upgrading to the latest MAT (version 1.11.0) did not help. I tried switching between different JDK runtimes. But none of them worked for me. Finally the following terminal based solution worked for me.

### open your favorite terminal and change directory to the Contents/MacOS sub-folder of MAT installation folder.
cd /Applications/mat.app/Contents/MacOS

### now run the executable
./MemoryAnalyzer

Of course, there are additional Benefit of running MAT via command line

  1. increased visibility to actual error / warning during application startup as well as continued execution. This will give us more clues while troubleshooting a problem
  2. We can override default JVM behavior by passing additional VM arguments. So for example, if we are analyzing a very big hprof file which requires more JVM memory, we can allocate more memory to MAT by following command

    ./MemoryAnalyzer -vmargs -Xmx1024m

  3. We can generate MAT reports in headless mode. This will be useful for profiling applications in an automated fashion. I will be covering this in a separate post later