KT-56789: Fix memory leak in CoreJrtFileSystem
CoreJrtFileSystem uses JrtFileSystemProvider provider to read contents of jrt-fs from JDK Implementation of FileSystems.newFileSystem causes metaspace memory leak that wasn't fixed until JDK 17, see https://bugs.openjdk.java.net/browse/JDK-8260621 When FileSystems.newFileSystem used to create jrt-fs on JDK9 with provided java.home value it creates new ClassLoader under-the-hood, which subsequently leaks due to aforementioned bug Remove conditional usage of `java.home` + FileSystems.newFileSystem and switch to use jrt-fs classloader cache regardless of compiler runtime JDK to reduce classloader leaks ^KT-56789
This commit is contained in:
committed by
Space Team
parent
0f384f5878
commit
253cdb1b8f
+18
@@ -136,6 +136,24 @@ class KotlinDaemonIT : KGPDaemonsBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-56789: Kotlin daemon does not triggers OOM in Metaspace on multiple invocations")
|
||||
@JdkVersions(versions = [JavaVersion.VERSION_11])
|
||||
@GradleWithJdkTest
|
||||
@GradleTestVersions(minVersion = TestVersions.Gradle.MAX_SUPPORTED)
|
||||
fun testMultipleCompilations(gradleVersion: GradleVersion, jdk: JdkVersions.ProvidedJdk) {
|
||||
project(
|
||||
"daemonJvmResourceLimits",
|
||||
gradleVersion,
|
||||
buildJdk = jdk.location
|
||||
) {
|
||||
for (iteration in 0..300) {
|
||||
build("clean", "assemble") {
|
||||
assertKotlinDaemonReusesOnlyOneSession()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun BuildResult.assertGradleClasspathNotLeaked() {
|
||||
assertOutputContains("Kotlin compiler classpath:")
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {}
|
||||
+1
@@ -0,0 +1 @@
|
||||
kotlin.daemon.jvmargs=-XX:MaxMetaspaceSize=128m -Xmx256m
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
fun main() {
|
||||
System.out.println("Hello, world!")
|
||||
println("Hello, world!")
|
||||
}
|
||||
Reference in New Issue
Block a user