Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JVM space exhausted when building a project through gradle

Receiving error message when building a project through gradle

Expiring Daemon because JVM Tenured space is exhausted

like image 648
Rob Blinsinger Avatar asked Dec 19 '18 15:12

Rob Blinsinger


People also ask

How to fix expiring Daemon because JVM heap space is exhausted?

This can be fixed by increasing the configured max heap size for the project. Through GUI: In the Settings, search for 'Memory Settings' and increase the IDE max heap size and Daemon max heap size as per the system RAM availability.

How much RAM should I allocate to gradle?

You should stay at the sensible level of 2–4 gigabytes for gradle and 1–2 for dex.

How increase Gradle build memory?

For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB. To do this set org. gradle. jvmargs=-Xmx2048M in the project gradle.

How do I stop all gradle daemons?

If you want to explicitly stop running Daemon processes for any reason, just use the command gradle --stop . This will terminate all Daemon processes that were started with the same version of Gradle used to execute the command.


1 Answers

This means the JVM doesn't have enough memory to compile the Java files. There's a couple of steps that can be taken.

  1. Run ./gradlew clean, which will remove everything including leftovers from previous builds which are no longer relevant.
  2. Run ./gradlew --stop, killing other gradle daemons which may be taking up memory.
  3. Allocate more memory. This can be done by adding the following to the gradle.properties file.

org.gradle.jvmargs=-Xms128m -Xmx1024m -XX:+CMSClassUnloadingEnabled

like image 139
Rob Blinsinger Avatar answered Oct 03 '22 21:10

Rob Blinsinger