Fix application environment keepalive handling
The previous changes to the disposer registration changes introduced a weird problem exposed in the Gradle (test?) environment, that caused a performance regression - it seems that keep alive system property in that setting was cleared at the time the disposer was called, causing app env disposal when keeping it alive was expected. This fix captures property value at the moment of disposer registration, making it similar in that respect to the previous variant and avoiding the performance degradation. #KT-56992 fixed
This commit is contained in:
committed by
Space Team
parent
1af19e6903
commit
cecf22e035
@@ -515,6 +515,8 @@ class KotlinCoreEnvironment private constructor(
|
||||
})
|
||||
}
|
||||
try {
|
||||
val disposeAppEnv =
|
||||
CompilerSystemProperties.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY.value.toBooleanLenient() != true
|
||||
// Disposer uses identity of passed object to deduplicate registered disposables
|
||||
// We should everytime pass new instance to avoid un-registering from previous one
|
||||
@Suppress("ObjectLiteralToLambda")
|
||||
@@ -528,7 +530,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
// Do not use this property unless you sure need it, causes Application to MEMORY LEAK
|
||||
// Only valid use-case is when Application should be cached to avoid
|
||||
// initialization costs
|
||||
if (CompilerSystemProperties.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY.value.toBooleanLenient() != true) {
|
||||
if (disposeAppEnv) {
|
||||
disposeApplicationEnvironment()
|
||||
} else {
|
||||
ourApplicationEnvironment?.idleCleanup()
|
||||
|
||||
Reference in New Issue
Block a user