Kotlin "compiler daemon terminated" in CI
The Kotlin compile daemon process died while compiling, so Gradle lost its connection. The most common trigger is the daemon JVM being killed under memory pressure.
What this error means
The build fails reporting the Kotlin daemon terminated or could not connect, sometimes with an OOM in the daemon log. It can be intermittent on a tight runner.
> Task :app:compileKotlin FAILED
Kotlin compile daemon ... terminated unexpectedly on attempt 1.
Could not connect to Kotlin compile daemonCommon causes
Daemon killed under memory pressure
The OS killed the daemon JVM (OOM) because the runner was short on RAM with the Gradle daemon and tests competing for memory.
Daemon heap too small
Modest default daemon heap is exceeded by large source sets and heavy annotation processing, crashing the daemon.
How to fix it
Raise daemon and Gradle JVM memory
Give the Kotlin daemon and Gradle more heap via gradle.properties.
# gradle.properties
org.gradle.jvmargs=-Xmx3g -XX:MaxMetaspaceSize=1g
kotlin.daemon.jvmargs=-Xmx2gReduce parallel pressure
- Lower
org.gradle.workers.maxon memory-tight runners. - Disable the daemon for one-shot CI if RAM is scarce.
- Split very large modules to lower per-compile memory.
Use a larger runner
For big multi-module builds, move to a higher-RAM runner. Latchkey managed runners self-heal transient daemon crashes by auto-retrying and offer larger-RAM sizes.
How to prevent it
- Set kotlin.daemon.jvmargs explicitly in CI.
- Cap parallel workers to fit available RAM.
- Right-size the runner to the module graph.