5

I am getting outOfMemoryError while building my project using gradle. I have tried many solution present in stackoverflow but nothing helped. Please find below the stacktrace

java.lang.OutOfMemoryError: Java heap space
        at com.sun.tools.javac.util.ByteBuffer.<init>(ByteBuffer.java:45)
        at com.sun.tools.javac.jvm.ClassWriter.<init>(ClassWriter.java:101)
        at com.sun.tools.javac.jvm.ClassWriter.instance(ClassWriter.java:145)
        at com.sun.tools.javac.main.JavaCompiler.<init>(JavaCompiler.java:295)
        at com.sun.tools.javac.main.JavaCompiler.instance(JavaCompiler.java:72)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.contextForNextRound(JavacProc
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingE
        at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:981)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
        at com.sun.tools.javac.main.Main.compile(Main.java:353)
        at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:115)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:45)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:33)

I have tried solutions like putting below lines in gradlew file.

GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\" \"-Xmx1024m\" \"-Xms256m\" \"-XX:MaxPermSize=1024m\""

Kindly help me to resolve this. Thanks in advance.

2
  • 1
    Try -Xms1024m, Does your gradle can compile? Whether will it throw memory not enougth tip? Commented Aug 4, 2015 at 10:59
  • there is an ejb project and gradle always fails while compiling this project but there is no compile time error in eclipse. Commented Aug 4, 2015 at 11:27

1 Answer 1

2

The max heap and the max perm size is configured with 1G and that will cause you trouble.

The perm generation size of 1G is allotted out of 1G total heap (100% of total heap is assigned to permanent generation). Reduce the permanent generation size to 128M and then try.

Update GRADLE_OPTS as like below.

-XX:MaxPermSize=128m
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.