Skip to content

ConcurrentBag containing a circular reference does not get garbage collected #23103

@halter73

Description

@halter73

ConcurrentBag has a ThreadLocal field that maintains references to whatever was added to it without being removed/cleared even after the ConcurrentBag itself becomes unreferenced.

Use your favorite search engine to find references to ConcurrentBag leaking memory to see that this has been a gotcha for developers for a while now. I don't think it should be necessary to explicitly clear the ConcurrentBag when you're finished with it.

@vancem @stephentoub

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions