diff --git a/topics/appendix/tools/gradle_intellij_plugin/tools_gradle_intellij_plugin_faq.md b/topics/appendix/tools/gradle_intellij_plugin/tools_gradle_intellij_plugin_faq.md index 64b724fd7..6c239a8f0 100644 --- a/topics/appendix/tools/gradle_intellij_plugin/tools_gradle_intellij_plugin_faq.md +++ b/topics/appendix/tools/gradle_intellij_plugin/tools_gradle_intellij_plugin_faq.md @@ -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 /projects/plugin-name/build/idea-sandbox/plugins/plugin-name/lib/ 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 gradle.properties file: + +```properties +kotlin.incremental.useClasspathSnapshot=false +``` + +See the [](using_kotlin.md#incremental-compilation) section for more details. +``` + diff --git a/topics/tutorials/using_kotlin.md b/topics/tutorials/using_kotlin.md index 8a869b01a..1d492ba0b 100644 --- a/topics/tutorials/using_kotlin.md +++ b/topics/tutorials/using_kotlin.md @@ -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 gradle.properties: + +```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/).