Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anything else I can do to deal with "GC Overhead Limit Exceeded" running Ant (Command Line)?

Tags:

java

android

ant

I'm trying to compile a very big, multi-project Android project using command line Ant. I was originally using Ant 1.8.3, but have since upgraded to 1.8.4 (in vain, it turns out). While I do have Eclipse installed (Indigo, updated today), the nature of this project precludes using Ant from within Eclipse for this.

The code seems to generate just fine, but when it gets to the "dex" phase of the operation it gets one of two errors, depending on my ANT_OPTS: "GC Overhead Limit Exceeded" or "Java Heap Space".

I googled and checked Stack. After finding various links (c.f. here, here, this Stack question, and this stack question as well), I modified my Ant options. (Many links cover what happens when this happens executing the Java code; my problem is actually in the Ant process that creates the Android APK for upload).

My ANT_OPTS environment variable is currently:

-Xms4g -Xmx4g -Xmn256m -XX:PermSize=256m -XX:MaxPermSize=1024m -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -XX:ParallelGCThreads=8

I tried turning off the GC Overhead Limit altogether using -XX:-UseGCOverheadLimit , but all that does is give me a Java Heap Space error instead of the GC Overhead Limit error. I've asked my co-workers about this, but they're also out of ideas.

Oh, one more "detail": I can use Eclipse to compile and load the project, and that seems to work "just fine"; however, the sheer number of projects required for this "meta-project" suggests that I try to get the Ant script working.

System Info:

  • OS: Windows 7 64 bit
  • Java: Sun, 1.6, 64 bit
  • Physical Memory: 8Gb
  • Android: SDK Tools: R20; Platform Tools: R12 (Updated today, 28 Jun)

Is there something else I can do? Another keyword to search for? Someplace else to look?

like image 202
John Price Avatar asked Jun 28 '12 21:06

John Price


1 Answers

A partial answer to this one. Thanks goes to the current respondents, who helped me track this down.

There are, apparently, two (possibly three?) different places where the Java VM opts need to be changed, depending on exactly where the error occurs. In this case, the ANT_OPTS are not getting passed to Dex.

I was able to solve the error by editing the DX batch file, changing:

set defaultXmx=-Xmx1024M

to

set defaultXmx=-Xmx4096M

The Obvious However: I should never need to change the dx batch file. Anyone happen to know the "right" way to change the Java Options being passed to Dex by Ant?

like image 112
John Price Avatar answered Sep 22 '22 05:09

John Price