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

JavaEclipseMemory

Java Problem Overview


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

Java Solutions


Solution 1 - Java

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 - Java

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 - Java

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 - Java

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

Solution 5 - Java

If Memory Analyser is used from Eclipse, then edit your eclipse.ini file to increase the vm argument to -Xmx1024m or higher. This worked for me. http://wiki.eclipse.org/index.php/MemoryAnalyzer/FAQ#Out_of_Memory_Error_while_Running_the_Memory_Analyzer

Solution 6 - Java

As suggested by others, its two step simple process:-

  1. open the MemoryAnalyzer.ini file from your MAT installation directory.

  2. change the default -Xmx1024m to a larger size for e.g. if you have to analyze a 4GB heap dump then you can replace -Xmx1024m with -Xmx5g or -Xmx6g

For more details refer:- https://better-coding.com/solved-eclipse-mat-java-heap-space-error/

Solution 7 - Java

If you are using Mac, try running the executable inside the mat.app 'folder' with -data option, by which you can specify a writable path:

cd mat.app/Contents/MacOS
./MemoryAnalyzer -data <writable_path>

Solution 8 - Java

For my experience add in MemoryAnalyzer.ini, Xms and Xmx to the max as your materiel possibilities. G1GC is faster and -XX:-UseGCOverheadLimit is need because gc usage can be high and time consuming, and maybe -XX:+UseStringDeduplication is the key to consume less memory

-vmargs
-Xms8g
-Xmx8g
-XX:-UseGCOverheadLimit
-XX:+UseG1GC
-XX:+UseStringDeduplication

Solution 9 - Java

I tried all the solutions here as well, while still getting the same error and the reason eclipse was trying to open the .hprof file as a text file due to wrong or unknown file type / editor association.

Solution: Right click on the file, select open with, then select Others, and select Eclipse Memory Analyzer.

Worked with 700MB dump, and worked with 2G dump on an eclipse heap of about 600M.

Solution 10 - Java

An internal error has occurred. Java heap space

Ans: GO to Your Project Work space open .setting folder Delete all file of .setting folder. after you can compile now there is no error Like Heap space Enjoy :)

Solution 11 - Java

You may reduce your application memory limit, and then again take a dump. Eclipse Memory Analyser puts dump file to memory - I suspect that your Eclipse has less memory than the limit of application.

You can also do the opposite and increase the memory limit for Eclipse, but if your application works on a server, it will be hard to match in size of memory.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGavinView Question on Stackoverflow
Solution 1 - JavacodeiseeView Answer on Stackoverflow
Solution 2 - JavatkincherView Answer on Stackoverflow
Solution 3 - JavaAbhishek GargView Answer on Stackoverflow
Solution 4 - JavaRussell CohenView Answer on Stackoverflow
Solution 5 - JavaGoodluckView Answer on Stackoverflow
Solution 6 - JavaAbhishek PhoenixzView Answer on Stackoverflow
Solution 7 - JavasnowfoxView Answer on Stackoverflow
Solution 8 - JavaMr_ThorynqueView Answer on Stackoverflow
Solution 9 - JavamibrahimView Answer on Stackoverflow
Solution 10 - JavaHemang RamiView Answer on Stackoverflow
Solution 11 - JavawojandView Answer on Stackoverflow