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.
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.
Open the Job in Studio, and navigate to the Advanced > Run tab below the designer view. Click the plus [+] sign next to the JVM parameters window, and a dialog will open where you can add the -XX:-UseGCOverheadLimit flag.
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.
(idea courtesy of this answer from Scott Barta)
In my case, to increase the heap-size looks like this:
Using Android Studio 1.1.0
android {
dexOptions {
incremental true
javaMaxHeapSize "2048M"
}
}
Put the above code in your Build.gradle file.
This new issue is caused by the latest version of Android.
Go to your project root folder, open gradle.properties
, and add the following options:
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true
Then add these changes in your build.gradle
file:
dexOptions {
incremental = true
preDexLibraries = false
javaMaxHeapSize "4g" // 2g should be also OK
}
Android Studio 3.5.3
Find the Memory Settings (Cmd + Shift + A on Mac or click on Help and start typing "Memory Settings") under Preferences/ Settings and increase the IDE Heap Size and/ or the Daemon Heap Size to your satisfaction
I disable my Instant Run by:
Menu Preference → Build → Instant Run "Enable Instant Run to hot swap code"
I guess it is the Instant Run that makes the build slow and creates a large size pidXXX.hprof file which causes the AndroidStudio gc overhead limit exceeded.
(My device SDK is 19.)
For me non of the answers worked I saw here worked. I guessed that having the CPU work extremely hard makes the computer hot. After I closed programs that consume large amounts of CPU (like chrome) and cooling down my laptop the problem disappeared.
For reference: I had the CPU on 96%-97% and Memory usage over 2,000,000K by a java.exe process (which was actually gradle related process).
Add this to build.gradle file
dexOptions {
javaMaxHeapSize "2g"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With