Java "CodeCache is full. Compiler has been disabled" - Fix in CI
The JVM filled its JIT code cache - the native region holding compiled machine code - so it disabled the JIT compiler and reverted to interpreting bytecode. Long-running build/test JVMs that compile many methods can exhaust the default cache.
What this error means
The log shows CodeCache is full. Compiler has been disabled. and Try increasing the code cache size using -XX:ReservedCodeCacheSize=. The build may still finish but is dramatically slower once the JIT is off.
Java HotSpot(TM) 64-Bit Server VM warning: CodeCache is full.
Compiler has been disabled.
Java HotSpot(TM) 64-Bit Server VM warning: Try increasing the code cache size
using -XX:ReservedCodeCacheSize=Common causes
JIT code cache exhausted
A long-lived JVM (a reused daemon, a big test suite) compiles enough hot methods to fill the reserved code cache. Once full, HotSpot disables further compilation.
Default ReservedCodeCacheSize too small
The default cache can be too small for large builds with heavy tiered compilation, so it fills before the workload completes.
How to fix it
Raise ReservedCodeCacheSize for the build JVM
Give the JIT more room so the compiler is not disabled mid-build.
# Maven
export MAVEN_OPTS="-XX:ReservedCodeCacheSize=512m"
# Gradle (gradle.properties)
# org.gradle.jvmargs=-Xmx2g -XX:ReservedCodeCacheSize=512mReduce JVM longevity in CI
A fresh JVM per build avoids accumulating compiled code across runs.
./gradlew --no-daemon build # do not reuse a long-lived daemon's code cacheHow to prevent it
- Set
-XX:ReservedCodeCacheSizeon long-running build/test JVMs. - Use
--no-daemon/fresh forks so compiled code does not accumulate across builds. - Watch for the warning in logs - a disabled JIT silently slows everything after it.