Out of memory with jack

1.2k Views Asked by At

I'm testing the new compilation chain to start using lambdas.

My build.gradle file contains:

android {
    ...
    compileSdkVersion 23
    buildToolsVersion "24 rc3"

    dexOptions {
        jumboMode true
    }

    defaultConfig {
        applicationId "my.app.id"
        minSdkVersion 14
        targetSdkVersion 23
        multiDexEnabled true

        jackOptions {
            enabled true
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

I'm using Android Studio 2.1.1.

When I build the app the compilation takes ages and then ends with an Out of memory error:

Execution failed for task ':app:compileAppNameJavaWithJack'.

java.lang.RuntimeException: java.lang.OutOfMemoryError: GC overhead limit exceeded

Sometimes the compilation just hangs when performing:

:app:compileMyAppNameDebugJavaWithJack

I found in the troubleshooting section here a way to fix it but I can't find the .jack file with the configuration. In this bug report someone mentioned that the file could have been renamed to jack.settings but I can't find that file either.

Do you know where the file is? Do you know how to fix the Out of memory error?

2

There are 2 best solutions below

0
On BEST ANSWER

I managed to fix the issue setting:

org.gradle.jvmargs=-Xmx2048M

in the gradle.propertiesfile

Check here for more info about the setting

0
On

See also this question, which solved this problem for me:

Android source code compile error: "Try increasing heap size with java option '-Xmx<size>'"

I find that jack's virtual size is around ~8G by the time my build is done.