{
  "id": "cicd/gradle-daemon-stopped-memory",
  "signature": "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",
  "signature_zh": "org.gradle.launcher.daemon.server.DaemonExpirationPeriodicCheck: 守护进程将在构建结束后停止，因为它运行了3小时5分钟，且构建环境已达到最大堆大小限制",
  "regex": "org\\.gradle\\.launcher\\.daemon\\.server\\.DaemonExpirationPeriodicCheck.*Daemon will be stopped.*maximum heap size",
  "domain": "cicd",
  "category": "resource_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "Gradle 守护进程因 JVM 内存分配不足而耗尽堆内存，通常是由于 CI 运行器 RAM 有限或未为大项目调整 Gradle JVM 参数。",
  "versions": [
    {
      "version": "Gradle 7.6",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Gradle 8.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Gradle 8.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Increasing Gradle daemon heap via GRADLE_OPTS without checking CI runner limits often still fails because the runner's total memory is capped.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "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.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Adding more parallel forks with maxParallelForks can increase memory pressure, making OOM worse.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set JVM args in gradle.properties: org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m. Then restart daemon: ./gradlew --stop && ./gradlew build",
      "success_rate": 0.85,
      "how": "Set JVM args in gradle.properties: org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m. Then restart daemon: ./gradlew --stop && ./gradlew build",
      "condition": "",
      "sources": []
    },
    {
      "action": "Reduce parallel test execution: In build.gradle, set 'tasks.withType(Test).configureEach { maxParallelForks = 1 }' and 'forkEvery = 50' to limit memory per fork.",
      "success_rate": 0.75,
      "how": "Reduce parallel test execution: In build.gradle, set 'tasks.withType(Test).configureEach { maxParallelForks = 1 }' and 'forkEvery = 50' to limit memory per fork.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "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."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties",
  "official_doc_section": null,
  "error_code": "GRADLE_OOM",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2023-09-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}