GRADLE_DAEMON_OOM
cicd
runtime_error
ai_generated
partial
Gradle 构建守护进程意外停止。守护进程将在构建结束后因内存不足而停止。
Gradle build daemon stopped unexpectedly. The daemon will be stopped at the end of the build after running out of memory.
ID: cicd/gradle-daemon-stopped-build-limit
80%修复率
85%置信度
1证据数
2023-06-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Gradle 7.x | active | — | — | — |
| Gradle 8.x | active | — | — | — |
| Gradle 8.5 | active | — | — | — |
根因分析
Gradle 守护进程超过了配置的最大堆内存大小,导致被 JVM 或操作系统终止,通常是由于 CI 运行器中的内存分配不足。
English
The Gradle daemon exceeded the configured maximum heap size, causing it to be killed by the JVM or the OS, typically due to insufficient memory allocation in CI runners.
官方文档
https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties解决方案
-
Set a lower maximum heap size and enable parallel garbage collection: add `org.gradle.jvmargs=-Xmx1024m -XX:+UseParallelGC` to gradle.properties
-
Reduce build parallelism by setting `org.gradle.workers.max=2` in gradle.properties, which limits concurrent tasks and memory usage.
-
In CI, set the GRADLE_OPTS environment variable: `export GRADLE_OPTS="-Xmx512m -XX:+UseG1GC"` before running the build
无效尝试
常见但无效的做法:
-
40% 失败
If the CI runner has a hard memory limit (e.g., 4 GB), the daemon may still be killed if total memory usage exceeds that limit.
-
30% 失败
This avoids the daemon but causes slower builds and may not resolve the underlying memory pressure if the build itself requires more memory.