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

user3008777 picture user3008777 · Nov 27, 2014 · Viewed 42.9k times · Source

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

Answer

user3008777 picture user3008777 · Nov 27, 2014

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