IR: clear callToSubstitutedDescriptorMap for each file to avoid leaking memory

This map is populated during psi2ir and is only used in
insertImplicitCasts, after which it makes sense to clear it, otherwise
it strongly references a lot of descriptors for calls in other files
which would never be used.
This commit is contained in:
Alexander Udalov
2020-10-22 14:59:39 +02:00
parent 7ac981d4d3
commit 4bd08e5e0c
2 changed files with 4 additions and 1 deletions
@@ -32,7 +32,7 @@ class GeneratorContext(
val constantValueGenerator: ConstantValueGenerator,
override val irBuiltIns: IrBuiltIns
) : IrGeneratorContext {
val callToSubstitutedDescriptorMap = mutableMapOf<IrDeclarationReference, CallableDescriptor>()
internal val callToSubstitutedDescriptorMap = mutableMapOf<IrDeclarationReference, CallableDescriptor>()
val sourceManager = PsiSourceManager()
@@ -90,7 +90,10 @@ class ModuleGenerator(
}
irFile.acceptChildrenVoid(IrSyntheticDeclarationGenerator(context))
insertImplicitCasts(irFile, context)
context.callToSubstitutedDescriptorMap.clear()
irFile.acceptVoid(AnnotationGenerator(context))
irFile.patchDeclarationParents()