Gradle "The Daemon will expire" / Low Disk Space - Fix in CI
Gradle warned that the daemon will be discarded after this build because the JVM is memory-constrained (or the machine is low on disk). It is a health warning that often precedes a slow build or an OOM in the next run.
What this error means
The log shows The Daemon will expire after the build after running out of JVM memory or available JVM memory is low. The build may still pass but is degraded, and subsequent builds can fail outright.
The message received from the daemon indicates that the daemon has disappeared.
# or, as a warning:
Expiring Daemon because JVM heap space is exhausted
The Daemon will expire after the build after running out of JVM memory.Common causes
Daemon heap too small for the build
When the daemon approaches its -Xmx, Gradle flags it for expiry to avoid a hard OOM. The configured heap is too small for the build graph.
Low free memory or disk on the runner
A runner low on RAM or disk triggers the expiry/health warnings; the daemon cannot reliably persist, and the next build may fail.
How to fix it
Give the daemon adequate heap
Raise the daemon JVM args to fit the build, within the runner’s RAM.
# gradle.properties
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512mDisable the daemon in ephemeral CI
A one-shot CI build gets no benefit from a persistent daemon; disabling it keeps memory bounded to a single build.
./gradlew --no-daemon build
# or gradle.properties: org.gradle.daemon=falseHow to prevent it
- Run CI with
--no-daemonso daemon health is never a factor. - Size
org.gradle.jvmargsto the runner RAM. - Keep runner disk clear so low-disk warnings do not appear.