4

Here's a build issue that I am struggling with. I am trying to build Android 2.1 on Mac OS X 10.6.8 with jdk 1.5. The "make" command runs for a while and at the end, it says:

The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: Java heap space
    at com.sun.tools.javac.code.Scope.dble(Scope.java:150)
    at com.sun.tools.javac.code.Scope.enter(Scope.java:185)
    at com.sun.tools.javac.comp.MemberEnter.importAll(MemberEnter.java:129)
    at com.sun.tools.javac.comp.MemberEnter.visitTopLevel(MemberEnter.java:504)
    at com.sun.tools.javac.tree.Tree$TopLevel.accept(Tree.java:382)
    at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:383)
    at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:778)
    at com.sun.tools.javac.code.Symbol.complete(Symbol.java:355)
    at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:612)
    at com.sun.tools.javac.comp.Enter.complete(Enter.java:463)
    at com.sun.tools.javac.comp.Enter.main(Enter.java:441)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:404)
    at com.sun.tools.javac.main.Main.compile(Main.java:592)
    at com.sun.tools.javac.main.Main.compile(Main.java:544)
    at com.sun.tools.javac.Main.compile(Main.java:92)
    at util.build.JavacBuildStep.build(JavacBuildStep.java:69)
    at util.build.BuildDalvikSuite.handleTests(BuildDalvikSuite.java:504)
    at util.build.BuildDalvikSuite.compose(BuildDalvikSuite.java:170)
    at util.build.BuildDalvikSuite.main(BuildDalvikSuite.java:136)
main javac dalvik-cts-buildutil build step failed
make: *** [out/host/darwin-x86/obj/EXECUTABLES/vm-tests_intermediates/tests] Error 1

It seems that the java heap size is insufficient. I searched for this problem on Google which gave me several links such as:

These pages mainly suggest to add the "-Xmx" option to the JVM Options. I tried the following: Added this column in /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0-leopard/Resources/Info.plist"

VMOptions -Xms1024M -Xmx2048M

(I also tried setting VMOptions.x86_64 instead of VMOptions).

Following another link (osdir.com/ml/android-platform/2010-06/msg00097.html), I also changed the following line in build/core/definitions.mk file inside the android build directory.

$(hide) java -Xmx512M -jar $(HOST_OUT_JAVA_LIBRARIES)/proguard-4.0.1.jar \

to

$(hide) java -Xmx2048M -jar $(HOST_OUT_JAVA_LIBRARIES)/proguard-4.0.1.jar \

None of the above has helped. I have few questions:

  • Is it possible to change system wide java heap size on Mac OS X and is that the right way to go? If so, whether the change I did in Info.plist file would achieve that?
  • Or is it that I have to change the heap size specifically for the android build? If so, how should I do it?

Edit

Just an update: I tried building android 3.1 with jdk 1.6 and the build went fine. (even without setting the "-Xmx" option for jdk 1.6). I still don't know what's the problem while building 2.1 with jdk 1.5.

Community
  • 1
  • 1
user541064
  • 333
  • 2
  • 7

2 Answers2

0

I think there's a separate way to raise the heap limit of the dexing operation. Add this to your android closure in your build.gradle file:

dexOptions {

    javaMaxHeapSize "4g"

}

and see if that helps.

see this link: https://groups.google.com/forum/#!topic/adt-dev/r4p-sBLl7DQ

Mumin Asaad
  • 180
  • 9
0

Sometimes the OutOfMemoryErroris not due scarce of Heap. Try increasing the PermGen:

-XX:PermSize=40m
-XX:MaxPermSize=240m

Sometimes is also caused by a not well dimensioned both Young and Ternured. And some others is due a long time doing a Full GC and collecting a low percentage.

Regards.

ssedano
  • 8,322
  • 9
  • 60
  • 98
  • Udo, thanks for your reply. Where should I set these options? I am new to the Android/Java. so i do not know much abt VM. Secondly, I looked for the error I am getting. It is "java.lang.OutOfMemoryError: Java heap space" Where as when i searched for permgen, one needs to do these settings when one has "java.lang.OutOfMemoryError: PermGen space" In that case, will setting those options will help me to solve my issue? – Harish J Aug 04 '11 at 11:29
  • I would go for build/core/definitions.mk. If it works I will update my answer to state this. This might help since it configures max mem on perm size. Leaving more space to heap. – ssedano Aug 05 '11 at 08:07