Is there anything else I can do to deal with "exceeding the GC upper limit" when running Ant (command line)?

I am trying to compile a very large project with multiple Android projects using the Ant command line. I originally used Ant 1.8.3, but since then I upgraded to 1.8.4 (it turns out in vain). Although I have Eclipse installed (Indigo, updated today), the nature of this project precludes using Ant from within Eclipse to do this.

The code seems to be generated just fine, but when it comes to the “dex” phase of the operation, it gets one of two errors, depending on my ANT_OPTS : “GC upper limit exceeded” or “Java Heap Space”.

I googled and checked the stack. After finding various links (cf here , here , this question is on the stack and this question is on the stack ), I changed the Ant settings. (Many links cover what happens when it happens while executing Java code, my problem is actually in the Ant process that creates the Android APK for download).

My environment variable ANT_OPTS currently:

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

I tried disabling the GC upper limit using -XX:-UseGCOverheadLimit , but all that does is give me a Java Heap Space error instead of a GC upper limit error. I asked my colleagues about this, but they also have no ideas.

Oh, another “detail”: I can use Eclipse to compile and download the project, and this seems to work “perfectly”; however, the sheer number of projects needed for this "metaproject" suggests that I am trying to get Ant script to work.

System Information:

  • OS: Windows 7 64 bit
  • Java: Sun, 1.6, 64 bit
  • Physical memory: 8 GB
  • Android: SDK Tools: R20; Platform Tools: R12 (updated today, June 28)

Is there anything else I can do? Another search keyword? Anywhere else to see?

+4
source share
3 answers

Partial answer to this question. Thanks to my current respondents who helped me track this.

There are apparently two (maybe three?) Different places where you need to change the selection of Java VM, depending on where exactly the error occurs. In this case, ANT_OPTS not transmitted to Dex.

I was able to resolve this error by editing the DX batch file by changing:

 set defaultXmx=-Xmx1024M 

to

 set defaultXmx=-Xmx4096M 

Obvious However : I do not need to change the dx batch file. Does anyone possibly know the “right” way to change the Java parameters passed to Dex to Ant?

+2
source

This is similar to what happens when an application slowly terminates from a heap. If you have a GC control limit set, the JVM dies quickly. If you do not, the application will continue to go a little longer, spending more and more GC'ing time ... and then finally die.

If this was your application, you should check for leaks. But since this is a well-known and (supposedly) well-tested third-party application, the easiest attempt is to try ... increase the heap size.

Another thing is to disable CMS. There is no reason to use CMS for batch compilation: GC pauses do not matter. Just use the bandwidth collector. (This probably won't solve the heap size issue, but it should make your builds faster.)

+2
source

I believe what you are looking for:

 -XX:-UseGCOverheadLimit 
0
source

All Articles