diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs index 99fda2800d5a1..0573222b6791b 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs @@ -23,7 +23,7 @@ namespace ILCompiler { - public abstract class Compilation : ICompilation + public abstract class Compilation : ICompilation, IDisposable { protected readonly DependencyAnalyzerBase _dependencyGraph; protected readonly NodeFactory _nodeFactory; @@ -67,6 +67,7 @@ protected Compilation( _methodILCache = new ILCache(ilProvider, NodeFactory.CompilationModuleGroup); } + public abstract void Dispose(); public abstract void Compile(string outputFileName); public abstract void WriteDependencyLog(string outputFileName); @@ -218,6 +219,7 @@ public interface ICompilation { void Compile(string outputFileName); void WriteDependencyLog(string outputFileName); + void Dispose(); } public sealed class ReadyToRunCodegenCompilation : Compilation @@ -638,5 +640,10 @@ protected override void ComputeDependencyNodeDependencies(List NodeFactory.CopiedFieldRva(field); + + public override void Dispose() + { + _corInfoImpls?.Clear(); + } } } diff --git a/src/coreclr/tools/aot/crossgen2/Program.cs b/src/coreclr/tools/aot/crossgen2/Program.cs index cd906d2799c1e..1a13309de32cc 100644 --- a/src/coreclr/tools/aot/crossgen2/Program.cs +++ b/src/coreclr/tools/aot/crossgen2/Program.cs @@ -632,6 +632,8 @@ private int Run(string[] args) if (_commandLineOptions.DgmlLogFileName != null) compilation.WriteDependencyLog(_commandLineOptions.DgmlLogFileName); + + compilation.Dispose(); } return 0;