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

其他格式: JSON · Markdown 中文 · English
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.

generic

官方文档

https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

解决方案

  1. Set a lower maximum heap size and enable parallel garbage collection: add `org.gradle.jvmargs=-Xmx1024m -XX:+UseParallelGC` to gradle.properties
  2. Reduce build parallelism by setting `org.gradle.workers.max=2` in gradle.properties, which limits concurrent tasks and memory usage.
  3. In CI, set the GRADLE_OPTS environment variable: `export GRADLE_OPTS="-Xmx512m -XX:+UseG1GC"` before running the build

无效尝试

常见但无效的做法:

  1. 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.

  2. 30% 失败

    This avoids the daemon but causes slower builds and may not resolve the underlying memory pressure if the build itself requires more memory.