GRADLE_OOM
cicd
resource_error
ai_generated
true
org.gradle.launcher.daemon.server.DaemonExpirationPeriodicCheck: Daemon will be stopped at the end of the build after running for 3 hours and 5 minutes because the build environment has reached its maximum heap size limit
ID: cicd/gradle-daemon-stopped-memory
80%Fix Rate
85%Confidence
1Evidence
2023-09-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Gradle 7.6 | active | — | — | — |
| Gradle 8.2 | active | — | — | — |
| Gradle 8.5 | active | — | — | — |
Root Cause
Gradle daemon runs out of heap memory due to insufficient JVM memory allocation for the build, typically when the CI runner has limited RAM or the Gradle JVM args are not tuned for large projects.
generic中文
Gradle 守护进程因 JVM 内存分配不足而耗尽堆内存,通常是由于 CI 运行器 RAM 有限或未为大项目调整 Gradle JVM 参数。
Official Documentation
https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_propertiesWorkarounds
-
85% success Set JVM args in gradle.properties: org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m. Then restart daemon: ./gradlew --stop && ./gradlew build
Set JVM args in gradle.properties: org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m. Then restart daemon: ./gradlew --stop && ./gradlew build
-
75% success Reduce parallel test execution: In build.gradle, set 'tasks.withType(Test).configureEach { maxParallelForks = 1 }' and 'forkEvery = 50' to limit memory per fork.
Reduce parallel test execution: In build.gradle, set 'tasks.withType(Test).configureEach { maxParallelForks = 1 }' and 'forkEvery = 50' to limit memory per fork.
中文步骤
Set JVM args in gradle.properties: org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m. Then restart daemon: ./gradlew --stop && ./gradlew build
Reduce parallel test execution: In build.gradle, set 'tasks.withType(Test).configureEach { maxParallelForks = 1 }' and 'forkEvery = 50' to limit memory per fork.
Dead Ends
Common approaches that don't work:
-
60% fail
Increasing Gradle daemon heap via GRADLE_OPTS without checking CI runner limits often still fails because the runner's total memory is capped.
-
70% fail
Disabling the daemon with --no-daemon may cause slower builds but doesn't fix OOM if the build itself is memory-hungry in the JVM process.
-
80% fail
Adding more parallel forks with maxParallelForks can increase memory pressure, making OOM worse.