Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak at AssemblyLoadContext unload #69263

Merged
merged 1 commit into from
May 12, 2022

Conversation

janvorli
Copy link
Member

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.

I have verified that with the fix applied, the memory doesn't grow at all in
that testing app.

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.
@janvorli janvorli added this to the 7.0.0 milestone May 12, 2022
@janvorli janvorli requested a review from jkotas May 12, 2022 17:29
@janvorli janvorli self-assigned this May 12, 2022
@ghost
Copy link

ghost commented May 12, 2022

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

Issue Details

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.

I have verified that with the fix applied, the memory doesn't grow at all in
that testing app.

Author: janvorli
Assignees: janvorli
Labels:

area-AssemblyLoader-coreclr

Milestone: 7.0.0

@janvorli janvorli merged commit 22162c7 into dotnet:main May 12, 2022
@janvorli janvorli deleted the fix-unload-leak branch May 12, 2022 23:32
@janvorli
Copy link
Member Author

/backport to release/6.0

@github-actions
Copy link
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/2321924911

@ghost ghost locked as resolved and limited conversation to collaborators Jun 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants