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.

Community
  • 1
  • 1
DavyJonesUA
  • 2,309
  • 2
  • 16
  • 21

9 Answers9

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

Ripon Al Wasim
  • 34,088
  • 37
  • 146
  • 165
user1457659
  • 4,504
  • 1
  • 12
  • 5
  • 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 06 '12 at 12:31
  • @user1457659 I cannot update the eclipse.ini - Access denied when attempting to save the changes. – Roy Hinkley Nov 22 '12 at 00:10
  • 11
    Do you need `--launcher.XXMaxPermSize 512m` twice? – Andrew Wyld May 17 '13 at 10:12
  • You are a life saver! Thanks! – Sohaib Jun 19 '13 at 06:11
  • 4
    What are the limits on these numbers? How high should I consider putting them? – easycheese Mar 02 '14 at 03:58
  • yeah Even I wanted to know the highest limit. I have like 8GBs of RAM. Is it proportional to my RAM ? – Muhammad Riyaz Mar 25 '14 at 14:36
  • 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 '14 at 04:07
  • For mac eclipse.ini folder exist in Eclipse.app/Contents/MacOS/eclipse.ini where the VM value needs to be increased. – arvindwill Aug 06 '14 at 10:02
  • 1
    What a relief! Thank you – sjkm Aug 06 '14 at 15:49
  • Perfect, thank you! Would give two ups if possible ;) – sjkm Sep 14 '14 at 22:09
  • +1 I come across this every time i setup a new environment. thanks for having this here to be documented. Until next time... – johnw182 Nov 15 '14 at 20:37
  • It saved my life like an ambulance :D – mertaydin Dec 15 '14 at 11:02
  • On a Mac OS X system, you can find eclipse.ini by right-clicking (or Ctrl+click) on the Eclipse executable in Finder, choose Show Package Contents, and then locate eclipse.ini in the MacOS folder under Contents. [link](http://wiki.eclipse.org/Eclipse.ini) – Azurespot Dec 24 '14 at 01:45
  • 4
    -XX:MaxPermSize=1024m -Xms1024m -Xmx2048m helped – kreker Jan 25 '15 at 21:05
  • As noted below: On OSX eclipse.ini file is on Eclipse.app/Contents/MacOS/ – Jonny Apr 01 '15 at 04:28
  • @user1457659 I have changed my eclipse.ini file with these lines and I can't open my Eclipse now !! =O ... help please!! Before I had the problem mentioned in the title and it showed a error message in eclipse, after I have modified that you said in your answer and I can't open Eclipse now ! – KryNaC May 20 '15 at 14:00
  • @Ripon Al Wasim I have tested your changes from image and it does not work for me ... my Eclipse does not open, it tries to load but at start it turns off! =O – KryNaC May 25 '15 at 08:22
  • i am increasing but still getting error Unable to execute dex: GC overhead limit exceeded – Krunal Shah Jul 15 '15 at 05:31
24

For me following steps worked

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

3)Restart eclipse

See here

Sunil Kumar Sahoo
  • 49,865
  • 50
  • 172
  • 240
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
Roadies
  • 3,171
  • 2
  • 27
  • 45
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

Akbar Sha Ebrahim
  • 1,774
  • 19
  • 33
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.

Viktor
  • 466
  • 3
  • 16
  • 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 02 '15 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.

Atul O Holic
  • 6,216
  • 4
  • 36
  • 72
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
Jorgesys
  • 114,263
  • 22
  • 306
  • 247
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)
Chad Bingham
  • 28,578
  • 19
  • 82
  • 110
anand krish
  • 3,029
  • 4
  • 32
  • 43
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!

tricknology
  • 933
  • 1
  • 14
  • 26