Fix project leaking in tests
The project was leaking via MockApplication -> LowMemoryWatcherManager -> List<Project> It happened due to unregistered disposable provided to the MockApplication
This commit is contained in:
committed by
teamcityserver
parent
f19dfd9d2a
commit
77fcb12af8
@@ -543,7 +543,14 @@ class KotlinCoreEnvironment private constructor(
|
||||
): KotlinCoreApplicationEnvironment {
|
||||
synchronized(APPLICATION_LOCK) {
|
||||
if (ourApplicationEnvironment == null) {
|
||||
val disposable = Disposer.newDisposable()
|
||||
val disposable = if (unitTestMode) {
|
||||
parentDisposable
|
||||
} else {
|
||||
// TODO this is a memory leak in the compiler, as this Disposable is not registered and thus is never disposed
|
||||
// but using parentDisposable as disposable in compiler, causes access to application extension points after
|
||||
// they was disposed, this needs to be fixed
|
||||
Disposer.newDisposable("Disposable for the KotlinCoreApplicationEnvironment")
|
||||
}
|
||||
ourApplicationEnvironment = createApplicationEnvironment(disposable, configuration, unitTestMode)
|
||||
ourProjectCount = 0
|
||||
Disposer.register(disposable, Disposable {
|
||||
|
||||
+1
@@ -76,6 +76,7 @@ abstract class AbstractLowLevelApiTest : TestWithDisposable() {
|
||||
protected fun runTest(path: String) {
|
||||
testDataPath = Paths.get(path)
|
||||
val testConfiguration = testConfiguration(path, configure)
|
||||
Disposer.register(disposable, testConfiguration.rootDisposable)
|
||||
val testServices = testConfiguration.testServices
|
||||
val moduleStructure = testConfiguration.moduleStructureExtractor.splitTestDataByModules(
|
||||
path,
|
||||
|
||||
Reference in New Issue
Block a user