Kotlin 1.8.20 Out of Memory issue (#1034)

* Kotlin 1.8.20 Out of Memory issue

* Kotlin 1.8.20 Out of Memory issue — review fixes
This commit is contained in:
Jakub Chrzanowski 2023-04-04 10:11:01 +02:00 committed by GitHub
parent 1ffd6159c0
commit 311ea36d9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 0 deletions

View File

@ -288,4 +288,17 @@ intellij {
It is also possible to refer to the sandbox directory of another Gradle project — to do that, point to the <path>/projects/plugin-name/build/idea-sandbox/plugins/plugin-name/lib/</path> directory.
### Kotlin compiler throws `Out of memory. Java heap space` error
Since Kotlin `1.8.20`, the Kotlin compiler has a [new incremental compilation approach](https://kotlinlang.org/docs/gradle-compilation-and-caches.html#a-new-approach-to-incremental-compilation) enabled by default that fails when reading IntelliJ SDK JAR files.
As a workaround, you can disable it by adding the following line to the <path>gradle.properties</path> file:
```properties
kotlin.incremental.useClasspathSnapshot=false
```
See the [](using_kotlin.md#incremental-compilation) section for more details.
```
<include from="snippets.md" element-id="missingContent"/>

View File

@ -119,6 +119,28 @@ See [Dependency on the standard library](https://kotlinlang.org/docs/gradle.html
> If you need to add Kotlin Standard Library to your **test project** dependencies, see the [](testing_faq.md#how-to-test-a-jvm-language) section.
>
### Incremental compilation
The Kotlin Gradle plugin supports [incremental compilation](https://kotlinlang.org/docs/gradle-compilation-and-caches.html#incremental-compilation), which allows tracking changes in the source files so the compiler handles only updated code.
The Kotlin `1.8.20` release has a [new incremental compilation approach](https://kotlinlang.org/docs/gradle-compilation-and-caches.html#a-new-approach-to-incremental-compilation) enabled by default.
Unfortunately, it is not compatible with the IntelliJ Platform — when reading large JAR files (like `app.js` or `3rd-party-rt.jar`), leading to the `Out of Memory` exception:
```
Execution failed for task ':compileKotlin'.
> Failed to transform app.jar to match attributes {artifactType=classpath-entry-snapshot, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for ClasspathEntrySnapshotTransform: .../lib/app.jar.
> Java heap space
```
To avoid this exception, add the following line to the <path>gradle.properties</path>:
```properties
kotlin.incremental.useClasspathSnapshot=false
```
You can find the current state of the issue in [KT-57757 Reduce classpath snapshotter memory consumption](https://youtrack.jetbrains.com/issue/KT-57757/Reduce-classpath-snapshotter-memory-consumption).
### Other Bundled Kotlin Libraries
Please see [Third-Party Software and Licenses](https://www.jetbrains.com/legal/third-party-software/).