213

When I downloaded the Git project OsmAnd and went to compile it, Eclipse returned these errors:

[Dex Loader] Unable to execute dex: GC overhead limit exceeded
[OsmAnd]     Conversion to Dalvik format failed: 
             Unable to execute dex: GC overhead limit exceeded

Google and Stackoverflow said that I must change -Xms40m -Xmx384m in eclipse.ini. Conversion to Dalvik format failed: Unable to execute dex: Java heap space.
I cleaned project and restarted Eclipse, but it did not help.

I found this link: Tips for Android developer: “Conversion to Dalvik format failed: Unable to execute dex: null” But I do not know which .jar from my project to change the input in. If anyone can help, I can send the project to them.

9 Answers 9

437

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

13
  • 8
    Thanks. I wonder why the defaults are still so absolutely inadequate, I do not think anyone is running eclipse with less than 512/1024 - I just went to even twice that. Plus I wish the settings were stored in some config file in my home directory instead of an ini file that is overwritten with every upgrade.
    – Yashima
    Nov 6, 2012 at 12:31
  • 11
    Do you need --launcher.XXMaxPermSize 512m twice? May 17, 2013 at 10:12
  • 4
    What are the limits on these numbers? How high should I consider putting them?
    – easycheese
    Mar 2, 2014 at 3:58
  • 5
    @MuhammadRiyaz It depends on your OS and whether you're using a 32-bit or 64-bit JVM. If you're on a 64 bit JVM, you can safely set it to anything smaller than your RAM size minus overhead for OS/other applications. On a 32 bit VM, you'll want to keep it smaller than about 1500M (on Linux) or 1100M (on Windows) because the VM needs to allocate contiguous address space, and that's a very limited resource for 32-bit apps.
    – Jules
    May 12, 2014 at 4:07
  • 4
    -XX:MaxPermSize=1024m -Xms1024m -Xmx2048m helped
    – k4dima
    Jan 25, 2015 at 21:05
24

For me following steps worked

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

3)Restart eclipse

See here

1
  • 11
    On OSX eclipse.ini file is on Eclipse.app/Contents/MacOS/ Jan 6, 2015 at 7:56
7

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
5

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

1

After 12 hours with this error and no success with changing the eclipse.ini file I finally found the correct solution. In my environment variables there was a variable named "_JAVA_OPTIONS" containing the value "-Xmx512M". Changing this value to the same value as in eclipse.ini (-Xmx4096M) I was once again able to export my project to an APK file.

1
  • actually this can be a realy important tip, you can delete the _JAVA_OPTIONS from your system variables (use rapid environment editor) otherwise proguard might start to complain for some reason. Thanks a lot to Viktor
    – Simon
    Jul 2, 2015 at 14:22
1

I DO NOT know the reason behind this work-around, but it works for me all the time when all of the above don't.

Do not start eclipse from a short-cut or a link. Always open it from the eclipse.exe in your eclipse folder, the very folder which holds the eclipse.ini

Note - I tried only for linux.

1

To avoid this annoyable message, i had to change my configuration as follows:

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120913-

144807
-product
com.android.ide.eclipse.adt.package.adtproduct
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
1024m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.6
-XX:MaxPermSize=256m
-Xms512m
-Xmx1024m

based on the answer marked as correct, changing

-XX:MaxPermSize=256m
-Xms512m
-Xmx1024m

and:

--launcher.XXMaxPermSize
1024m
1
1) Open eclipse.ini file
2)change
-Xms40m
-Xmx512m
to 
-Xms512m
-Xmx1024m
3)Restart eclipse

The same eclipse.ini file will be located in Eclipse in this root path of eclipse itself like:

C:\Users\username\Downloads\adt-bundle-windows-x86_64-20140702\eclipse\eclipse.ini

The same file will be located in android studio project:-

C:\Users\username\AppData\Local\Android\sdk\tools\lib\monitor-x86_64\monitor(Type:Configuration settings)
0

If these answers don't work (They didn't for me) then try this:

1) Make a copy of your .metadata folder in your workspace.

2) Delete your .metadata directory AFTER MAKING A COPY

3) Open Eclipse and close Eclipse.

4) Copy your plugins folder from your old .metadata to your new .metadata

5) Import all the projects back into your workspace

6) Keep Calm and Code On!

Not the answer you're looking for? Browse other questions tagged or ask your own question.