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

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

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:
open the MemoryAnalyzer.ini file
change the default -Xmx1024m to a larger size

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 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:
Right Click on Eclipse icon and select Show Package Content.
Go to Contents>Eclipse
Open Eclipse.ini
Change value -Xmx1024m to -Xmx2048m
Restart Eclipse

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

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

As suggested by others, its two step simple process:-
open the MemoryAnalyzer.ini file from your MAT installation directory.
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/

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

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>

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.

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

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.

Related

Memory overflow Java

I think that my Java Program exceeded the usage of memory allowed... this is the error that shows up in Eclipse:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at Main.main(Main.java:228)
before than trying an implementation with better memory handling, is there any way basically to augment the memory to allocate for the program ? I would like to see the program terminating and showing the result at least.
You can allocate more memory to the process by using the -Xmx flag:
java -Xmx2G YourProgram
Will allocate 2 Gigabytes of memory to the process.
You can do this in Eclipse by going to Run Configurations, the Arguments section and adding -Xmx 2G to the VM arguments.
Increasing memory size is good, but you should also consider that probably your program has some memory leak and you really should bother about it.
You can increase heap size using the cmd-line flags
For example:
java -Xmx6g myprogram
You can get a full list (or a nearly full list, anyway) by typing java -X.
As I don't think your program is using that much memory, I suspect your program is having a memory leak somewhere.
If you could give Main.java:200 till Main.java:250 we could check for any leaks.
If you are sure your program is using that amount of memory you can either run
java -Xmx2G -jar foo.jar in the Command Prompt (Windows) or Terminal (Mac OS X or Linux)
or, if you're running your program in Eclipse under Linux, do the following:
1) Make sure Eclipse is closed
2) Open your favorite text editor at your eclipse.ini file (Default location: /usr/lib/eclipse/eclipse.ini)
3) Search for --Xmx512M and increase this number (i.e. --Xmx2G)
4) Save the file and restart Eclipse
For any explaination about --Xmx and --Xms I refer to Eclipse memory settings when getting "Java Heap Space" and "Out of Memory"
Happy coding :) -Charlie

Keep getting not enough space for object heap in java

I am trying to run the vFileServe of project anarchy, but i always have this error even though i set a parameter on my java
Here is my error
Loading deploy parameters from Source\Vision\Samples\Engine\FileServe\FileServe_
android_arm_vs2010_anarchy.vcxproj_Dev.deploy
Creating apkFile ../../../../../Bin/android_arm_vs2010_anarchy/Dev/libFileServe.
apk for library ../../../../../Bin/android_arm_vs2010_anarchy/Dev/libFileServe.s
o
Android platform (SDK) android-10
Removing dir AndroidTemp\armeabi-v7a
Making a raw (so uncompressed) dir for the gdb server, native .so etc...
Done
Generating classes.dex file
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Command finished with error code '1'
Here is my java parameter
I tried putting -XX:MaxHeapSize=256m -Xmx512m also but doesnt work either
Whats wrong here? Thanks
I don't know about this particular software but limiting JVM heap size to 512Mb max may be insufficient.
Try setting initial heap size to 512 Mb and maximum to 2 Gb with -Xms512m -Xmx2g
Fo some reason the environment variable of java has been removed. I have to set it again. That solve the problem

Is there a workaround to solve "Java heap space" memory error when the max heap value has been already specified?

I'm running a WEKA classifier (J48 with an input .arff file composed of 3 fields, field 1 has ~27k distinct attributes, field 2 ~ 500k values) in a latest generation Macbook Pro with 8GB RAM.
I increased the java heap space to the maximum possible using the -Xmx parameter:
java -Xmx7G -cp weka-3-6-10/weka.jar weka.classifiers.trees.J48 -t
myfiles/loc_linear.arff -i
however when I run the classifier (after about 10 minutes) I get the error "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space".
Evidently 8GB RAM is not enough with my input file. Does this mean the only solution to this is having a more powerful hardware (e.g. 16GB RAM or a very powerful server/cluster)?
Would there be any workaround to this issue? (e.g. reducing the input file? If so, which would be in your opinion the criteria to apply in the reduction?). Any other ideas or suggestions?
If you are running the Weka GUI on a Mac OS X machine, you can edit a plist configuration file. I followed instructions from the Weka mailing list.
cd into /Applications/weka-XXX.app/Contents , or wherever your weka executable was installed.
There will be a file called Info.plist there. I suggest you save a copy of that file to another location, as you'll need to change it in the next step.
Open the weka-XXX.app/Contents/Info.plist (XML) file in your favorite text editor and look for a block that says "VMOptions". There should be a value that says "-Xmx256M" which specifies the memory. Change that value to something bigger, like "-Xmx1024M".
Start Weka.
From your cited line of code it seems you are running Weka from the simple command line interface. If that is the case, then the answer is the same as this [question] (Increase heap to avoid Out of Memory Error in WEKA.)
You can't increase the heap size from the command line interface. Instead I believe you should increase the heap size in the RunWeka.ini file as stated in Weka's instructions

Hibernate - OutOfMemoryError - java heap size

I'm currently having this problem where I am executing a query that will load large of records. At first execution, it is successful, but when I
execute again, I am having java heap size out of memory.
I Know I can increase java heap size using command line, but that requires a compiled jar file.
But I am currently on the development process, so how can I increase java heap size in that case?
Im using Elipse as my IDE.
Thanks for any response.
It doesn't require a compiled jar file. Choose Run - Run configurations... - Select your run configuration - Arguments tab. Then enter the appropriate command line argument in the VM arguments text box: -Xmx1024m for example.
You can modify the eclipse.ini file located inside of our eclipse directory .There you will find Xms40m Xmx256m parameter with some value , you can increase it to Xms256m Xmx1024m . Then check whether outofmemory error is still there . If its there then try tuning these parameter slightly increasing and check.
Apperently that was not enough for an answer... well, let me just copy the text from those answers instead :S
You can use the environment variable _JAVA_OPTIONS to set the default heap size. This will change the heap size for all Java programs. Like this:
export _JAVA_OPTIONS="-Xmx1g"

How to increase heap size for jBoss server

I have an upload files scenario in my project. When I'm trying to upload the large files it's giving me an OutOfMemory error. That error is related to Java heap size.
How can you increase the heap size in Java and which file do I need to alter for this? I'm using jboss 5.1 server for running my application.
You can set it as JVM arguments the usual way, e.g. -Xms1024m -Xmx2048m for a minimum heap of 1GB and maximum heap of 2GB. JBoss will use the JAVA_OPTS environment variable to include additional JVM arguments, you could specify it in the /bin/run.conf.bat file:
set "JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx2048m"
However, this is more a workaround than a real solution. If multiple users concurrently uploads big files, you'll hit the same problem sooner or later. You would need to keep increasing memory for nothing. You should rather configure your file upload parser to store the uploaded file on temp disk instead of entirely in memory. As long as it's unclear which parser you're using, no suitable answer can be given. However, more than often Apache Commons FileUpload is used under the covers, you should then read the documentation with "threshold size" as keyword to configure the memory limit for uploaded files. When the file size is beyond the threshold, it would then be written to disk.
On wildfly 8 and later, go to /bin/standalone.conf and put your JAVA_OPTS there, with all you need.
Edit the following entry in the run.conf file. But if you have multiple JVMs running on the same JBoss, you might want to run it via command line argument of -Xms2g -Xmx4g (or whatever your preferred start/max memory settings are.
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms2g -Xmx4g -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true
Use -Xms and -Xmx command line options when runing java:
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
For more help type java -X in command line.
I have mentioned the configuration changes needed for the increase of heap size in Windows or Linux environments.
Linux:
bin/standalone.conf
Check for the following line,
JAVA_OPTS
and change it accordingly to suit your heap size needs
-Xms1303m: initial heap size in megabytes
-Xmx1303m: maximum heap size in megabytes
JAVA_OPTS="-Xms1024M -Xmx2048M -XX:MaxPermSize=2048M -XX:MaxHeapSize=2048M"
Windows:
bin/standalone.conf.bat
JAVA_OPTS="-Xms1024M -Xmx2048M -XX:MaxPermSize=2048M -XX:MaxHeapSize=2048M"
Now restart the server and it will work without prompting any heap size errors.
For more information you can refer this link below.
https://access.redhat.com/documentation/en-us/jboss_enterprise_application_platform/5/html/getting_started_guide/adjust_memory_settings
Look in your JBoss bin folder for the file run.bat (run.sh on Unix)
look for the line
set JAVA_OPTS, (or just JAVA_OPTS on Unix) at the end of that line add -Xmx512m. Change the number to the amount of memory you want to allocate to JBoss.
If you are using a custom script to start your jboss instance, you can add the set JAVA_OPTS option there as well.
In my case, for jboss 6.3 I had to change JAVA_OPTS in file jboss-eap-6.3\bin\standalone.conf.bat and set following values -Xmx8g -Xms8g -Xmn3080m for jvm to take 8gb space.
Add following option in jboss in bin/standalone.conf.bat
set "JAVA_OPTS=-Xms1G -Xmx1G -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=1024m"
What to change?
set "JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx2048m"
Where to change? (Normally)
bin/standalone.conf(Linux) standalone.conf.bat(Windows)
What if you are using custom script which overrides the existing settings? then?
setAppServerEnvironment.cmd/.sh (kind of file name will be there)
More information are already provided by one of our committee members!
BalusC.
You can increase or set the heap size configuration i.e. -Xms/Xmx or any other JVM options in the JBoss application server in JAVA_OPTS JVM options in standalone.conf(Linux) & standalone.conf.bat file in Windows.
JAVA_OPTS="-Xms2048M -Xmx2048M"

Categories