Skip to content
Latchkey

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.

gradle
> Task :app:compileKotlin FAILED
Kotlin compile daemon ... terminated unexpectedly on attempt 1.
Could not connect to Kotlin compile daemon

Common 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
# gradle.properties
org.gradle.jvmargs=-Xmx3g -XX:MaxMetaspaceSize=1g
kotlin.daemon.jvmargs=-Xmx2g

Reduce parallel pressure

  1. Lower org.gradle.workers.max on memory-tight runners.
  2. Disable the daemon for one-shot CI if RAM is scarce.
  3. 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.

Frequently asked questions

What causes ""Kotlin compile daemon ... terminated""?
The OS killed the daemon JVM (OOM) because the runner was short on RAM with the Gradle daemon and tests competing for memory.
How do I fix "Kotlin compile daemon ... terminated"?
Give the Kotlin daemon and Gradle more heap via gradle.properties.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card