Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio: GC overhead limit exceeded

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> java.lang.OutOfMemoryError: GC overhead limit exceeded

Tried:

dexOptions {
    javaMaxHeapSize "4g"
}

That seems to be the only solution available online.

But still it exceeds the limit on 2nd build, unless I kill the studio task and restart, which makes it work for the 1st time.

Definitely not many dependencies in the build.gradle

build.grade

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.xxxxx.android"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 8
        versionName "1.3"
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.jakewharton:butterknife:6.1.0'
    compile 'com.squareup.okhttp:okhttp:2.3.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.3.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'de.greenrobot:eventbus:2.4.0'
    compile 'com.google.android.gms:play-services-location:+'
}
like image 877
Archie.bpgc Avatar asked Jan 27 '16 10:01

Archie.bpgc


People also ask

What causes GC overhead limit exceeded?

OutOfMemoryError: GC overhead limit exceeded" error indicates that the NameNode heap size is insufficient for the amount of HDFS data in the cluster. Increase the heap size to prevent out-of-memory exceptions.

How do I fix GC overhead limit exceeded in eclipse?

From the root of the Eclipse folder open the eclipse. ini and change the default maximum heap size of -Xmx256m to -Xmx1024m on the last line. NOTE: If there is a lot of memory available on the machine, you can also try using -Xmx2048m as the maximum heap size.

What is GC overhead in spark?

The GC Overhead Limit Exceeded error is an indication of a resource exhaustion i.e. memory. The JVM throws this error if the Java process spends more than 98% of its time doing GC and only less than 2% of the heap is recovered in each execution.


3 Answers

This is a problem of not enough java heap for gradle, not IDE

I increased Java Heap in gradle.properties

org.gradle.jvmargs=-Xms1024m -Xmx4096m
like image 61
nick252 Avatar answered Sep 28 '22 23:09

nick252


Increase the IDE memory (file studio.vmoptions)

http://tools.android.com/tech-docs/configuration

My settings:

-Xms256m
-Xmx3080m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=225m
-XX:+UseCompressedOops
like image 45
Cristian Holdunu Avatar answered Sep 29 '22 01:09

Cristian Holdunu


If anyone still facing the issue and there is no impact on increasing the IDE memory and gradle.properties than invalidate cache/restart is the last option for you. In my case it is working after invalidate cache/restart

like image 43
Fazal Hussain Avatar answered Sep 28 '22 23:09

Fazal Hussain