Unable to execute dex: GC overhead limit exceeded in Eclipse

It can be fixed by changing the VM values in Eclipse.ini. Set the values to 512 and 1024 as below:

openFile
--launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms512m
-Xmx1024m

The changed area in image enter image description here


For me following steps worked

1) Open eclipse.ini file
2)changed
-Xms40m
-Xmx512m
to 
-Xms512m
-Xmx1024m

3)Restart eclipse

See here


Let me assume this problem caused due to the Android XML, because of very frequently you're opening it

These following two issues on StackOverFlow are realted with each other:

Every time I click on an Android XML file in Eclipse, it loads data for all API versions

and

Unable to execute dex: GC overhead limit exceeded

I found one more solution to resolve this problem other than increasing the VM values or downgrading to an older ADT version (22.6.2 or 23.2)

Note:

Some of the older ADT versions which won't load the XML each and every time you open so there is no memory overflow to cause this GC overhead limit exceeded as discussed on the first thread

Solution:

At the bottom of the eclipse there will be Trash can symbol which states Run Garbage Collector. Whenever you close an XML file of android don't forget to just click on the Trash Can or Run Garbage Collector to release memory. This way you can protect the workspace from crashing this kind of error :D

This could be an ultimate solution because you can't increase the VM value beyond your RAM limit if you very frequently open your android XML especially if you do lot of UI works like me :P

I hope this would help everyone who will come to this thread :)

Keep Calm and Code On


eclipse.ini look like this.

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20140116-2212
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-XX:MaxPermSize=256m
-Xms40m
-Xmx512m
-Xmx1024m