How do I Save the Heap (Dump to a File) in Eclipse? - java

I'm getting this error when I run or debug my GA/AI from MyEclipse:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
eclipse.ini looks like this:
-showsplash com.genuitec.myeclipse.product
--launcher.XXMaxPermSize 256m
-vmargs
-Xms128m
-Xmx512m
-Duser.language=en
-XX:PermSize=128M
-XX:MaxPermSize=256M
MyEclipse is called like this:
"C:\Program Files\MyEclipse 6.0\eclipse\eclipse.exe" -vm "C:\Program Files\MyEclipse 6.0\jre\bin\javaw.exe" -vmargs -Xms1448M -Xmx1448M
bumping the vm settings up from this:
"C:\Program Files\MyEclipse 6.0\eclipse\eclipse.exe" -vm "C:\Program Files\MyEclipse 6.0\jre\bin\javaw.exe" -vmargs -Xms80M -Xmx1024M
has had no effect. So I'm trying to get it to dump the heap to a file, but placing these:
-XX:+HeapDumpOnCtrlBreak
-XX:+HeapDumpOnOutOfMemoryError
in the Program arguments has had no effect. How do I get something to work with more memory usage analysis? jstack, for instance, is not currently available on Windows platforms. And using SendSignal has no effect that I can see.

There are a number of ways to get heap dumps. Here are some I've used:
-XX:+HeapDumpOnOutOfMemoryError should get you dump if you hit your OOM.
Connect with VisualVM (free) and use its GUI to force a heap dump
Use one of the many good commercial profilers (JProfiler, YourKit, ...)
Use jmap (see below) to force a dump from a running process
If you're running Java 6, jmap should work on Windows. This might be useful if you want to dump the heap and you haven't hit your OOM. Use Windows Task Manager to find the pid of your Java app, and in a console run this:
jmap -dump:format=b,file=c:\heap.bin <pid>
In addition to VisualVM, the Eclipse Memory Analyzer (also free) can help you analyze what's eating up all the space once you've got the dump.

-XX:+HeapDumpOnOutOfMemoryError should be put in "VM Arguments" not "Program Arguments"

You can monitor memory usages with JConsole.
The jstat also will help.

Related

How to build project with loging current -xmx -xms

in my /.AndroidStudio2.2/studio64.vmoptions stated
-Xms8192m
-Xmx8192m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=200m
-XX:+UseCompressedOops
when I run project, just before Error:java.lang.OutOfMemoryError: GC overhead limit exceeded , system monitor shows that all jave related procces use ~4g memory.
Is there method to log which vmoptions are actually used?

java.lang.OutOfMemoryError: Java heap space in Eclipse, regardless of the settings

I am testing a simple recommender system built using Mahout in Eclipse.
If the preferences file is too big I am getting this error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.lang.String.substring(String.java:1939)
at java.lang.String.subSequence(String.java:1972)
at com.google.common.base.Splitter$SplittingIterator.computeNext(Splitter.java:612)
at com.google.common.base.Splitter$SplittingIterator.computeNext(Splitter.java:522)
at com.google.common.base.AbstractIterator.tryToComputeNext(AbstractIterator.java:64)
at com.google.common.base.AbstractIterator.hasNext(AbstractIterator.java:59)
at com.google.common.base.AbstractIterator.next(AbstractIterator.java:74)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.processLine(FileDataModel.java:408)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.processFile(FileDataModel.java:363)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.buildModel(FileDataModel.java:259)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.reload(FileDataModel.java:231)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:221)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:169)
at org.apache.mahout.cf.taste.impl.model.file.FileDataModel.<init>(FileDataModel.java:149)
at com.predictionmarketing.itemrecommend.ItemRecommend.main(ItemRecommend.java:35)
The file contains about 5 millions preference points.
I have already read several messages about this issue and my eclipse.ini is the following
-startup
../../../plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.200.v20140603-1326
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
3000m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-XX:MaxPermSize=3000m
-Xms3000m
-Xmx6000m
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
Basically I added -Xmx6000m and changed -Xmx and MaxPermSize (both) to 3000m.
I am not very fluent in Java so I don't know if the settings are correct, but during the execution I can see something like
Heap size: 55M of total 3017M max 5996 mark 55M
Which seems to reflect the settings.
The weird thing is that I don't see much increase of the heap size during execution, also the free memory in my computer (mac os) is around 800M.
Where is the problem?
If the preferences file is smaller, everything works fine.
The eclipse.ini settings are only used for the Eclipse application.
When you Run a Java application from Eclipse you need to go to 'Run > Run Configurations'. Find your application in the Java application list. On the 'Arguments' tab enter your memory settings in the 'VM arguments' section.
Read Java Heap Space - How does -Xmx work exactly?
and
http://javarevisited.blogspot.gr/2011/05/java-heap-space-memory-size-jvm.html
Java Heap is not the same for every system i think that in Windows for example the default java Heap is 60 Mb

Can't solve "Java heap space" error in eclipse

While running my Java code in Eclipse IDE, I got the error:
Exception in thread "D3D Screen Updater" Exception in thread
"AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
I searched for this error and tried solutions described here and here, but they did not work.
I changed these parameters in eclipse.ini:
--launcher.XXMaxPermSize
512M
-Xms40m
-Xmx512m
to:
--launcher.XXMaxPermSize
1024M
-Xms512m
-Xmx2048m
EDIT:
I changed this parameters at Run Configurations:
But I still get the same error. Am I missing something?
The memory settings in eclipse.ini is allocated to Eclipse IDE only,
not the program you want to run. A very common mistake is updated the
heap size in eclipse.ini, and expects it to solve above out of memory
problem.
http://www.mkyong.com/eclipse/eclipse-java-lang-outofmemoryerror-java-heap-space/
Where is the "vmargs" option? If you set the min/max heap, you probably need to do it on the main process, not the launcher.
See the Eclipse FAQ item on setting VM options.
That launcher PermSize opt is a bit ridiculous. Unless you know it is launcher PermSize causing the OOM, keep it at the default of 256m.
[EDIT]
As pointed out else-thread, if this is happening when you run your Java program from Eclipse, you tweak those settings within the "Run Configuration" for that program, not Eclipse.ini.
Also, remember that you can tweak the VM options all you want, but if the program wants to eat all the resources on the box before it OOMs, no amount of tweaking can mitigate this.
If we are using windows try this:
Try setting a Windows System Environment variable called _JAVA_OPTIONS with the heap size you want. Java should be able to find it and act accordingly
Below settings workes for me :
-Xms512m -Xmx1024m -XX:MaxPermSize=512m
Assuming you have 4gb or more RAM, try something like this in eclipse.ini(notice the capital/small letter "m"):
--launcher.XXMaxPermSize
1024M
--launcher.XXMaxPermSize
1024m
-vmargs
-Xms512m
-Xmx2048m

Not enough permanent generation memory. How increase memory?

I installed youtrack. Begin to adjust. And my message is shown:
"Not enough permanent generation memory. Please, refer to
documentation on how to increase it."
I went to the documentation. Sought there, tried to register at startup
exec $JAVA_HOME -Xms512m -Xmx1024m -jar $JAR"youtrack.jar" $PORT >> $LOG 2>&1 &
tried to set parameter.
java -XX:PermSize=1024m -XX:MaxPermSize=1024m -jar /usr/local/youtrack/youtrack.jar 8112
Still does not work. I use Ubuntu Server 10.04
This has worked for me:
java -XX:MaxPermSize=150m -Xmx512m -Djava.awt.headless=true -jar youtrack-<version>.jar 8080
JVM flag that controls PermGen size is -XX:MaxPermSize. Try to modify startup script for youtrack like this:
java -XX:MaxPermSize=1024m -Xmx1024m -jar /usr/local/youtrack/youtrack.jar 8112
Although, be advised that this may not work on Windows because Tomcat loves ignoring startup scripts. You may need to specify these JVM flags in Windows service properties window.
Or maybe a little bit fewer than 1024m, not sure you really need that much.

How can I modify my eclipse.ini settings to build large-scale java projects?

I am using IBM WebSphere Integration Developer (WID) which is based on Eclipse. We have a large web system built in this and all the projects are in the stream. It's pretty heavy. Every time I try to build all projects - it takes a really long time and eventually Eclipse runs out of memory.
These are my settings:
-startup
plugins\org.eclipse.equinox.launcher_1.0.101.R34x_v20081125.jar
-install
D:\IBM\WID7
--launcher.library
plugins\org.eclipse.equinox.launcher.win32.win32.x86_1.0.101.R34x_v20080731
--launcher.XXMaxPermSize
256m
-vm
jdk\jre\bin\j9vm\jvm.dll
-vmargs
-Xquickstart
-Xms768m
-Xss4m
-Xmaxf0.1
-Xminf0.05
-Xmx1300m
-Xmnx64m
-Xgcpolicy:gencon
-Xscmx96m
-Xshareclasses:name=IBMSDP_%u
-XX:MaxPermSize=448M
-XX:+UseParallelGC
-XX:+AggressiveHeap
-Dorg.eclipse.jdt.core.javamodelcache.ratio=0.0625
-Dosgi.requiredJavaVersion=1.5
-Dosgi.bundlefile.limit=100
What can I do to actually make Eclipse build all these projects? It does garbage collect but eventually even with GC, it uses everything up.
Assuming the j9 JVM works like the Oracle JVM, the settings above are setting your maximum heap space to 1300 MB. You can try increasing that amount if your system has enough free RAM to support a larger heap.
The line to edit is -Xmx1300m
One more thing to consider: are you certain that your memory errors are because of heap space running out? Keep in mind that the -Xmx setting only affects heap space, but a JVM uses memory for other purposes, too.

Categories