cicd resource_error ai_generated partial

org.gradle.launcher.daemon.server.DaemonExpirationPeriodicCheck: Daemon will be stopped at the end of the build after running out of JVM memory

ID: cicd/gradle-daemon-out-of-memory

Also available as: JSON · Markdown · 中文
85%Fix Rate
84%Confidence
1Evidence
2023-07-08First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Gradle 8.2 active
JDK 17 active
Gradle 7.6 active

Root Cause

Gradle daemon exceeded its allocated JVM heap memory, causing the daemon to expire and potentially fail the build due to OutOfMemoryError or GC overhead limit.

generic

中文

Gradle 守护进程超出了分配的 JVM 堆内存,导致守护进程过期,并可能因 OutOfMemoryError 或 GC 开销限制而导致构建失败。

Official Documentation

https://docs.gradle.org/current/userguide/performance.html

Workarounds

  1. 90% success Increase the Gradle daemon heap in gradle.properties: org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m. Adjust values based on runner memory (e.g., 4GB runner: -Xmx3072m).
    Increase the Gradle daemon heap in gradle.properties: org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m. Adjust values based on runner memory (e.g., 4GB runner: -Xmx3072m).
  2. 75% success Disable the daemon for memory-constrained CI by passing --no-daemon to Gradle, but this increases build time.
    Disable the daemon for memory-constrained CI by passing --no-daemon to Gradle, but this increases build time.

中文步骤

  1. Increase the Gradle daemon heap in gradle.properties: org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m. Adjust values based on runner memory (e.g., 4GB runner: -Xmx3072m).
  2. Disable the daemon for memory-constrained CI by passing --no-daemon to Gradle, but this increases build time.

Dead Ends

Common approaches that don't work:

  1. 50% fail

    Restarting the daemon without increasing memory will cause the same failure on the next build.

  2. 30% fail

    Setting -Xmx too high on a CI runner with limited RAM can cause the OS to OOM-kill the process.