Eclipse Memory Analyser,but always shows An internal error occurred?

java.lang.OutOfMemoryError: Java heap space
Dumping heap to java_pid2584.hprof ...
Heap dump file created [106948719 bytes in 4.213 secs]
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2760)
at java.util.Arrays.copyOf(Arrays.java:2734)
at java.util.ArrayList.ensureCapacity(ArrayList.java:167)
at java.util.ArrayList.add(ArrayList.java:351)
at Main.main(Main.java:15)

But when i open head dump java_pid2584.hprof via Eclipse Memory Analyser,but there is always message:

An internal error occurred during: 
"Parsing heap dump from **\java_pid6564.hprof'".Java heap space

Solution 1:

The problem is that Eclipse Memory Analyser does not have enough heap space to open the Heap dump file.

You can solve the problem as follows:

  1. open the MemoryAnalyzer.ini file

  2. change the default -Xmx1024m to a larger size

Solution 2:

Note that on OS X, to increase the memory allocated to MAT, you need to right-click mat.app and show the package contents. The MemoryAnalyzer.ini file is under /Contents/Eclipse.

Solution 3:

Solution for same issue for Memory Analyzer plugin in Eclipse in MAC OS X El Capitan.

I was facing the same issue but with the eclipse plugin and I did not have any Memory Analyzer App in Applications Folder. The solution which worked for me was:

  1. Right Click on Eclipse icon and select Show Package Content.
  2. Go to Contents>Eclipse
  3. Open Eclipse.ini
  4. Change value -Xmx1024m to -Xmx2048m
  5. Restart Eclipse

Solution 4:

On OS X 11.5 (El Cap) modifying MemoryAnalyzer.app/Contents/MacOS/MemoryAnalyzer.ini does not work! This is because it's looking for the MemoryAnalyzer.ini in a different place.

On my computer, it was looking for:

MemoryAnalyzer.app/Contents/Eclipse/MemoryAnalyzer.ini but the real .ini file was: MemoryAnalyzer.app/Contents/MacOS/MemoryAnalyzer.ini.

In order for your changes to take effect, copy the existing .ini file into the new location.

To find where MemoryAnalyzer is looking for the ini file, you can run:

sudo su
cd ...MemoryAnalyzer.app/Contents/MacOS/
dtruss ./MemoryAnalyzer 2>&1 | grep ini