How to solve java.lang.OutOfMemoryError: GC overhead limit exceeded error in android studio

android, garbage-collection, out-of-memory

Solution

I solved this issue by adding

dexOptions { 
          incremental true 
          javaMaxHeapSize "4g" 
} 

to the android closure in build.gradle file. Found this answer in

OutOfMemoryError: GC overhead limit exceeded

Problem

I am using `android studio 1.0 RC` for 64 bit linux. When I run my application I am getting ``` "java.lang.OutOfMemoryError: GC overhead limit exceeded" ``` When I searched on how to solve this error I got solutions like add: - -XX:-UseGCOverheadLimit to studio.vmoptions or studio64.vmoptions - -Xmx2000m to studio.vmoptions or studio64.vmoptions etc. These did not work for me. Please help. Thanks in advance

Original source