Eclipse memory settings when getting "Java Heap Space" and "Out of Memory"
When trying to launch and run a flex/java project in eclipse I kept getting a "Out of Memory Exception" and "Java Heap Space" using Eclipse, Tomcat and a JRE.
While researching trying to adjust the memory settings I found three places to adjust these:
Eclipse.ini
The JRE Settings under Window > Preferences
Catalina.sh or Catalina.bat
What are the differences between setting -xms and -xmx in these different places and what does is mean?
Is there any way to verify these memory settings are being set accordingly?
What are the optimal -xms and -xmx settings for a computer with 2gb of RAM?
Any other memory tips?
Thanks.
-xms is the start memory (at the VM start), -xmx is the maximum memory for the VM
- eclipse.ini : the memory for the VM running eclipse
- jre setting : the memory for java programs run from eclipse
- catalina.sh : the memory for your tomcat server
First of all, I suggest that you narrow the problem to which component throws the "Out of Memory Exception".
This could be:
- Eclipse itself (which I doubt)
- Your application under Tomcat
The JVM parameters -xms
and -xmx
represent the heap's "start memory" and the "maximum memory". Forget the "start memory". This is not going to help you now and you should only change this parameter if you're sure your app will consume this amount of memory rapidly.
In production, I think the only parameter that you can change is the -xmx
under the Catalina.sh or Catalina.bat files. But if you are testing your webapp directly from Eclipse with a configured debug environment of Tomcat, you can simply go to your "Debug Configurations" > "Apache Tomcat" > "Arguments" > "VM arguments" and set the -xmx
there.
As for the optimal -xmx
for 2gb, this depends a lot of your environment and the number of requests your app might take. I would try values from 500mb up to 1gb. Check your OS virtual memory "zone" limit and the limit of the JVM itself.
Found 2 issues in our case.
The Memory was halting and we where mandatory to set the startup perm size to higher value. I guess it was using memory faster then able to allocate it. In our case. -XX:PermSize=256m -XX:MaxPermSize=256m
We are using Clearcase and the plugin from Rational Clearcase SCM (7.0.0.2) was used in Eclipse. The plugin was the case of why Eclipse crashed. And at the moment we do not know why, but could be good to know for others. Was forced to disable it.
Tomcat in Eclipse does not use catalina.sh or bat. To setup memory for managed Tomcat use VM settings in server run configuration
My FLashBuilder is crashing all the time when I try to release a new version or I abuse of the "Mark Occurrences" and "Link with editor" features.
I have improved significantly my flash performance by following this steps http://www.redcodelabs.com/2012/03/eclipse-speed-up-flashbuilder/
Especially by setting the FlashBuilder.ini to the following configuration
-vm
C:/jdk1.6.0_25/bin
-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.100.v20110502
-product
org.eclipse.epp.package.jee.product
–launcher.defaultAction
openFile
–launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
–launcher.XXMaxPermSize
256m
–launcher.defaultAction
openFile
-vmargs
-server
-Dosgi.requiredJavaVersion=1.5
-Xmn128m
-Xms1024m
-Xmx1024m
-Xss2m
-XX:PermSize=128m
-XX:MaxPermSize=128m
-XX:+UseParallelGC
My hardware configuration is intel i3 cpu, 4gb DDR3, windows 7 64Bit.