# OutOfMemoryError after migration from Kotlin 1.6.10 to 1.6.21

**URL:** <https://discuss.kotlinlang.org/t/outofmemoryerror-after-migration-from-kotlin-1-6-10-to-1-6-21/24896>\
**Category:** Support\
**Created:** [May 25, 2022, 3:24pm UTC](https://discuss.kotlinlang.org/t/outofmemoryerror-after-migration-from-kotlin-1-6-10-to-1-6-21/24896 "2022-05-25T15:24:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tprochazka](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/tprochazka/32/6436_2.png) [@tprochazka](https://discuss.kotlinlang.org/u/tprochazka)\
**Post date:** [May 25, 2022, 3:24pm UTC](https://discuss.kotlinlang.org/t/outofmemoryerror-after-migration-from-kotlin-1-6-10-to-1-6-21/24896/1 "2022-05-25T15:24:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Alexey.Belkov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/alexey.belkov/32/5215_2.png) [@Alexey.Belkov](https://discuss.kotlinlang.org/u/Alexey.Belkov)\
**Post date:** [May 26, 2022, 8:01am UTC](https://discuss.kotlinlang.org/t/outofmemoryerror-after-migration-from-kotlin-1-6-10-to-1-6-21/24896/2 "2022-05-26T08:01:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![tprochazka](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/tprochazka/32/6436_2.png) [@tprochazka](https://discuss.kotlinlang.org/u/tprochazka)\
**Post date:** [June 24, 2022, 12:26pm UTC](https://discuss.kotlinlang.org/t/outofmemoryerror-after-migration-from-kotlin-1-6-10-to-1-6-21/24896/3 "2022-06-24T12:26:28Z")

</div>

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

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.

---

<div class="post-metadata">

**Author:** ![tprochazka](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/tprochazka/32/6436_2.png) [@tprochazka](https://discuss.kotlinlang.org/u/tprochazka)\
**Post date:** [June 24, 2022, 7:53pm UTC](https://discuss.kotlinlang.org/t/outofmemoryerror-after-migration-from-kotlin-1-6-10-to-1-6-21/24896/4 "2022-06-24T19:53:41Z")

</div>

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