Description
When running ./gradlew compileKotlin multiple times with the Gradle daemon enabled (the default), the compiler eventually crashes with:
e: java.lang.OutOfMemoryError: Metaspace
at scala.collection.immutable.List$.<clinit>(List.scala:682)
...
at org.jetbrains.kotlin.formver.viper.Verifier.<init>(Verifier.kt:27)
at org.jetbrains.kotlin.formver.plugin.compiler.ViperPoweredDeclarationChecker.check(ViperPoweredDeclarationChecker.kt:82)
Suspected Root Cause
ViperPoweredDeclarationChecker.check() is called once per function declaration. On line 82, it constructs a new Verifier instance for every function: val verifier = Verifier()
Each Verifier construction initializes a Config with seqOf(...), which triggers loading of Scala's collections library (List$, Seq$, etc.) into JVM Metaspace. Because the Gradle daemon is a long-lived process, these class definitions accumulate across builds until Metaspace is exhausted.
Steps to Reproduce
- Enable conversionTargetsSelection("all_targets") in the Gradle plugin config
- Have a project with several Kotlin functions to verify
- Run ./gradlew compileKotlin --rerun-tasks three or more times in succession
Expected Behavior
Metaspace usage should remain stable across repeated compilations.
Workaround
Add to gradle.properties:
kotlin.daemon.jvm.options=-XX:MaxMetaspaceSize=512m
This delays the OOM but does not fix the underlying issue.
Description
When running .
/gradlew compileKotlinmultiple times with the Gradle daemon enabled (the default), the compiler eventually crashes with:Suspected Root Cause
ViperPoweredDeclarationChecker.check()is called once per function declaration. On line 82, it constructs a new Verifier instance for every function:val verifier = Verifier()Each Verifier construction initializes a Config with
seqOf(...), which triggers loading of Scala's collections library (List$,Seq$, etc.) into JVM Metaspace. Because the Gradle daemon is a long-lived process, these class definitions accumulate across builds until Metaspace is exhausted.Steps to Reproduce
Expected Behavior
Metaspace usage should remain stable across repeated compilations.
Workaround
Add to gradle.properties:
kotlin.daemon.jvm.options=-XX:MaxMetaspaceSize=512m
This delays the OOM but does not fix the underlying issue.