Last updated February 26, 2022 at 02:30 AM
This troubleshooting is for resolving the Message: GC overhead limit exceeded Stack: OutOfMemoryError android error.
In this post we show you 2 methods of solving the following error:
Message: GC overhead limit exceeded Stack: OutOfMemoryError - Expiring Daemon because JVM heap space is exhausted
[bctt tweet=”Message: GC overhead limit exceeded Stack: OutOfMemoryError android – Troubleshooting” username=”tedidevblog”]
Problem: Expiring Daemon because JVM heap space is exhausted
By deploying a source code in our continuous integration system, we encountered an error that was not present during development. The snippet of the full error message appears like this:
Message: GC overhead limit exceeded Stack: OutOfMemoryError:
At the end of the console message, you will also find this message.
Expiring Daemon because JVM heap space is exhausted
To resolve this type of error, we had to try several solutions, some of which are currently obsolete. In this help, we share with you the solutions that worked in the next section.
Solution for Message: GC overhead limit exceeded Stack: OutOfMemoryError android
The problem is solved by configuring the file gradle.property . Our goal is to increase the size of memory allocated to the virtual machine. There are 2 ways to do this.
By the script:
Add this script in gradle.property the following script:
org.gradle.jvmargs = -Xmx1536M
You just have to allocate the amount of memory needed to run the build with gradle. If the size is too small or too large, the performance of Gradle risk of being degraded.
Graphically
Go to File> settings> memory settings as in the image below:

You just have to configure the option Gradle daemon max heap size and change the value as appropriate. When you validate your configuration, the Programs will automatically modify your file gradle.property.
If both solutions do not work, you will only have to increase the maximum memory allocated. In my case, 1536M was enough to solve the problem and pass the validation tests through my continuous integration server.
Last updated February 26, 2022 at 02:30 AM
Conclusion
You may be interested in Failed to apply plugin [id 'com.android.internal.application'] -Android studio -Troubleshooting et Angular - Fundamentals and architecture of the application - Tutorial