Skip to content
Latchkey

Gradle "Unable to start the daemon" / Bad JVM Args - Fix in CI

The Gradle daemon JVM could not even start. The JVM args in org.gradle.jvmargs (or GRADLE_OPTS) request more memory than the runner has, or contain an invalid flag, so the process aborts at launch.

What this error means

Gradle fails before any build with Unable to start the daemon process and a JVM message such as Could not reserve enough space for object heap or Unrecognized VM option.

gradle output
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
... Error occurred during initialization of VM
Could not reserve enough space for 4194304KB object heap

Common causes

org.gradle.jvmargs -Xmx exceeds runner RAM

A daemon -Xmx4g on a 2–3 GB runner cannot reserve its heap, so the daemon JVM aborts at startup.

Invalid or unrecognized JVM flag

A typo or a flag removed in the current JDK (e.g. an obsolete GC option) makes the JVM refuse to start.

How to fix it

Lower the daemon heap to fit the runner

Set org.gradle.jvmargs to a heap that fits, leaving room for the OS and forked workers.

gradle.properties
# gradle.properties
org.gradle.jvmargs=-Xmx1536m -XX:MaxMetaspaceSize=512m

Validate the JVM args

Check every source of daemon JVM args and remove invalid flags.

Terminal
echo "$GRADLE_OPTS"
# test args against the runner JDK directly:
java -Xmx1536m -XX:MaxMetaspaceSize=512m -version

How to prevent it

  • Size org.gradle.jvmargs to the runner RAM, not a fixed large value.
  • Audit GRADLE_OPTS and gradle.properties for stale or invalid flags.
  • Test JVM args against the target JDK before pinning them.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →