[release/6.0] Fix memory leak at AssemblyLoadContext unload #69334
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #69263 to release/6.0
/cc @janvorli
Customer Impact
Without this fix, an application that creates and unloads collectible AssemblyLoadContext very often gets memory consumption growing indefinitely. So after many iterations, they may get out of memory exception. A customer has experienced this in a stress testing application they have created for their plugin system. The fix in 6.0 is very important for them.
Testing
CoreCLR tests, libraries tests, customer's repro application.
The customer has also tested a patched version of coreclr.dll on their systems and verified it fixes the issues they were seeing.
Risk
Low, it affects only collectible AssemblyLoadContext and the deletion of the data structure was clearly missing.