Gavin
Gavin

Reputation: 971

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

Upvotes: 97

Views: 92692

Answers (12)

jaks
jaks

Reputation: 4607

Tried with Eclipse Memory Analyzer 1.15.0 and Mac OS 13.6.5.

cd /Applications/MemoryAnalyzer.app/Contents/MacOS

./MemoryAnalyzer -vmargs -Xms4g -Xmx5g -XX:-UseGCOverheadLimit -XX:+UseG1GC -XX:+UseStringDeduplication

Upvotes: 0

Mr_Thorynque
Mr_Thorynque

Reputation: 2002

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

Upvotes: 8

tkincher
tkincher

Reputation: 771

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.

Upvotes: 64

Abhishek Phoenixz
Abhishek Phoenixz

Reputation: 51

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/

Upvotes: 5

snowfox
snowfox

Reputation: 2098

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>

Upvotes: 3

Abhishek Garg
Abhishek Garg

Reputation: 2288

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

Upvotes: 17

Russell Cohen
Russell Cohen

Reputation: 725

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

Upvotes: 14

codeisee
codeisee

Reputation: 1742

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

Upvotes: 153

Goodluck
Goodluck

Reputation: 61

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

Upvotes: 6

mibrahim
mibrahim

Reputation: 67

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.

Upvotes: 0

Hemang Rami
Hemang Rami

Reputation: 13

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 :)

Upvotes: -2

wojand
wojand

Reputation: 142

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.

Upvotes: -3

Related Questions