Debugger: Fix memory leak in conditional breakpoints (KT-31195)
This commit is contained in:
@@ -176,6 +176,10 @@ class CodeFragmentCodegen private constructor(
|
||||
codeFragment.putUserData(INFO_USERDATA_KEY, info)
|
||||
}
|
||||
|
||||
fun clearCodeFragmentInfo(codeFragment: KtCodeFragment) {
|
||||
codeFragment.putUserData(INFO_USERDATA_KEY, null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getCodeFragmentInfo(codeFragment: KtCodeFragment): CodeFragmentCodegenInfo {
|
||||
return codeFragment.getUserData(INFO_USERDATA_KEY) ?: error("Codegen info user data is not set")
|
||||
|
||||
+11
-7
@@ -89,17 +89,21 @@ class CodeFragmentCompiler(private val executionContext: ExecutionContext) {
|
||||
val codegenInfo = CodeFragmentCodegenInfo(classDescriptor, methodDescriptor, parameterInfo.parameters)
|
||||
CodeFragmentCodegen.setCodeFragmentInfo(codeFragment, codegenInfo)
|
||||
|
||||
KotlinCodegenFacade.compileCorrectFiles(generationState, CompilationErrorHandler.THROW_EXCEPTION)
|
||||
try {
|
||||
KotlinCodegenFacade.compileCorrectFiles(generationState, CompilationErrorHandler.THROW_EXCEPTION)
|
||||
|
||||
val classes = generationState.factory.asList().filterClassFiles()
|
||||
.map { ClassToLoad(it.internalClassName, it.relativePath, it.asByteArray()) }
|
||||
val classes = generationState.factory.asList().filterClassFiles()
|
||||
.map { ClassToLoad(it.internalClassName, it.relativePath, it.asByteArray()) }
|
||||
|
||||
val methodSignature = getMethodSignature(methodDescriptor, parameterInfo, generationState)
|
||||
val functionSuffixes = getLocalFunctionSuffixes(parameterInfo.parameters, generationState.typeMapper)
|
||||
val methodSignature = getMethodSignature(methodDescriptor, parameterInfo, generationState)
|
||||
val functionSuffixes = getLocalFunctionSuffixes(parameterInfo.parameters, generationState.typeMapper)
|
||||
|
||||
generationState.destroy()
|
||||
generationState.destroy()
|
||||
|
||||
return CompilationResult(classes, parameterInfo, functionSuffixes, methodSignature)
|
||||
return CompilationResult(classes, parameterInfo, functionSuffixes, methodSignature)
|
||||
} finally {
|
||||
CodeFragmentCodegen.clearCodeFragmentInfo(codeFragment)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLocalFunctionSuffixes(
|
||||
|
||||
Reference in New Issue
Block a user