OutOfMemoryError after migration from Kotlin 1.6.10 to 1.6.21

What happened in Kotlin between 1.6.10 and 16.20?
I’m unable to build my project after migration because of OutOfMemoryError.

Originally I have this setup
org.gradle.jvmargs=-Xmx8g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -Dfile.encoding=UTF-8 kapt.use.worker.api=true

It always failed on Out of memory: Java heap space usually on KAPT

I have no experimental setup like the parallel module compilation introduced in 1.6.20.

I tried to increase -Xmx8g up to 16g add -Dkotlin.daemon.jvm.options=-Xmx16g
Also removed kapt.use.worker.api=true.

Then I tried add also kotlin.daemon.jvmargs=-Xmx16g to gradle.properties or use kotlin.compiler.execution.strategy=in-process, only result was change the exception to

Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded

I tried also this JVM switch

-XX:+UseCompressedOops

It happens just when I build all flavors, when I build just one, usually from IDE, it works.
Is there any known memory leak in the new version of the Kotlin compiler?

Update: I update memory limits even more and build time goes over 2 hours and it ends with Execution timeout on TeamCity

No, I don’t think this is a known issue. Can you please report it to YouTrack with as much details as possible to investigate: logs, memory dump, ideally a sample project with steps to reproduce.

BTW, does it work better on 1.7.0-RC?

2 Likes

I solved it by returning to older version.
Now I tried to use final Kotlin 1.7.0 and it is the same :disappointed_relieved:

It is hard to provide more information since it is not open-sourced project and it probably happens just because it is a huge project.

I reported it here
https://youtrack.jetbrains.com/issue/KT-52962/OutOfMemoryError-during-project-building-since-Kotlin-1620