GRADLE_DAEMON_OOM cicd runtime_error ai_generated partial

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
1Evidence
2023-06-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Gradle 7.x active
Gradle 8.x active
Gradle 8.5 active

Root Cause

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

中文

Gradle 守护进程超过了配置的最大堆内存大小,导致被 JVM 或操作系统终止,通常是由于 CI 运行器中的内存分配不足。

Official Documentation

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

Workarounds

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

中文步骤

  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

Dead Ends

Common approaches that don't work:

  1. 40% fail

    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% fail

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