Outofmemoryerror: Gc Overhead Limit Exceeded Android
Solution 1:
Updated gradle plugin use R8 process by default to code shrinking. You can try this by adding following lines in gradle.proeprties.
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Solution 2:
The detail message "GC overhead limit exceeded" indicates that the garbage collector is running all the time and Java program is making very slow progress. After a garbage collection, if the Java process is spending more than approximately 98% of its time doing garbage collection and if it is recovering less than 2% of the heap and has been doing so far the last 5 (compile time constant) consecutive garbage collections, then a java.lang.OutOfMemoryError is thrown. This exception is typically thrown because the amount of live data barely fits into the Java heap having little free space for new allocations.
Action: Increase the heap size. The java.lang.OutOfMemoryError exception for GC Overhead limit exceeded can be turned off with the command line flag -XX:-UseGCOverheadLimit.
This was taken from Oracle Java Documentation
Solution 3:
GC overhead limit exceeded means that your app occupied all the heap and garbage collector cannot clean enough space to run the program.
So, there is too much necessary data in memory or memory leak (i.e. references which can be accessed from app root but no longer needed) exists in your application - only further app profiling can give you more details
Solution 4:
You can increase your allocated memory for the app by adding
android:largeHeap="true"to your manifest file and see if it solves your problem. But you should look for memory leaks in your app because the OutOfMemoryError is usually a consequence of bad memory management.
Post a Comment for "Outofmemoryerror: Gc Overhead Limit Exceeded Android"