From 9ed17b64f0dd071afaa4f2e9c507937c4e9571d2 Mon Sep 17 00:00:00 2001 From: Vadim Mishenev Date: Sat, 26 Nov 2022 01:11:53 +0200 Subject: Fix OOME: Metaspace (#2678) * Fix OOME: Metaspace * Add stress test * Run sample analysis from `Dispatchers.Default` --- .../main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'runners/gradle-plugin/src') diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt index a654f9d5..52e7d3df 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt @@ -89,7 +89,14 @@ abstract class AbstractDokkaTask : DefaultTask() { internal open fun generateDocumentation() { DokkaBootstrap(runtime, DokkaBootstrapImpl::class).apply { configure(buildDokkaConfiguration().toJsonString(), createProxyLogger()) - generate() + /** + * Run in a new thread to avoid memory leaks that are related to ThreadLocal (that keeps `URLCLassLoader`) + * Currently, all `ThreadLocal`s leaking are in the compiler/IDE codebase. + */ + Thread { generate() }.apply { + start() + join() + } } } -- cgit