Android java.lang.OutOfMemoryError: GC overhead limit exceeded
再用 Android Studio 编辑项目的时候,会出现如下错误。
1 | java.lang.OutOfMemoryError: GC overhead limit exceeded |
根据 Sun 的描述:
1
"if too much time is being spent in garbage collection: if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered, an OutOfMemoryError will be thrown."
首先更改 Android Studio 的运行内存,MacBook 在Content/bin/studio.vmoptions
,修改如下
1 | # |
之后在项目的build.gradle
中添加一个设置:
1 | exOptions { |
接下来运行就能通过。