Skip to content

Add to docs: AssemblyLoadContext is GC.Pinned #21708

@dave-yotta

Description

@dave-yotta

I've recently hit a problem with (catastrophic) file handle leaks due to non unloaded assemblies. The docs are clear that unloading happens after all references into the loaded assemblies are collected - however my subclass of the AssemblyLoadContext was storing such references. It was disposed/out of scope, but it turns out the implementation keeps a strong GCHandle to the AssemblyLoadContext, so my references despite being out of scope are not collected.

Please can we add to the bulletpoints at the top of the page something along the lines of:

 - The runtime keeps a strong GCHandle to the AssemblyLoadContext and will not be collected by the GC, so you will need to remove any references on the `AssemblyLoadContext` you have subclassed into loaded assemblies before the `Unload` will complete.

Thanks - related issue over here: dotnet/runtime#44679


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.


Associated WorkItem - 562695

Metadata

Metadata

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.dotnet-fundamentals/svcin-prThis issue will be closed (fixed) by an active pull request.

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions