Skip to content

Commit

Permalink
Fix memory leak at AssemblyLoadContext unload (#69334)
Browse files Browse the repository at this point in the history
I have found there was a small memory leak when unloading
AssemblyLoadContext. A customer had a quite extreme testing case that
ran millions of iterations of creating an AssemblyLoadContext, loading
some assemblies into it and then unloading it. After 80 million
iterations on their machine with 8GB memory, the testing app was getting
out of memory.

Using PerfView, I was able to locate the source of the leak. It was a
missing destruction of the Module::m_pJitInlinerTrackingMap.

Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
  • Loading branch information
github-actions[bot] and janvorli authored May 16, 2022
1 parent 15626cf commit 6a2204c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/coreclr/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,10 @@ void Module::Destruct()
m_file->Release();
}

#if defined(PROFILING_SUPPORTED)
delete m_pJitInlinerTrackingMap;
#endif

// If this module was loaded as domain-specific, then
// we must free its ModuleIndex so that it can be reused
FreeModuleIndex();
Expand Down

0 comments on commit 6a2204c

Please sign in to comment.