Problem
The :compileKotlin Gradle task fails during plugin development with the following error:
java.lang.RuntimeException: java.lang.OutOfMemoryError: GC overhead limit exceeded
The stack trace shows the Kotlin compiler daemon running out of heap while deserializing package metadata (JvmClassFileBasedSymbolProvider.computePackagePartsInfos). The build output includes:
FAILURE: Build failed with an exception.
Execution failed for task ':compileKotlin' (registered by plugin 'org.jetbrains.kotlin.jvm').
> Not enough memory to run compilation. Try to increase it via 'gradle.properties':
kotlin.daemon.jvmargs=-Xmx<size>
Cause
The Kotlin compiler daemon's default heap is too small for projects with many dependencies or a large classpath. When the FIR pipeline deserializes protobuf metadata for package parts, it can consume several gigabytes of heap. When the daemon runs out, the JVM's GC overhead limit fires and surfaces the OutOfMemoryError.
Resolution
Add the following to gradle.properties:
kotlin.daemon.jvmargs=-Xmx5g
This gives the Kotlin compiler daemon 5 GB of heap. Lower to -Xmx3g on systems with less available RAM.
Comments
0 comments
Please sign in to leave a comment.