Skip to content

Weak pointers can lead to a space leak #3

@TeofilC

Description

@TeofilC

This library creates a weak pointer with a finalizer each time that we attach a context to a thread that doesn't have a context.

This can lead to a space leak if we also detach contexts from threads manually (eg, using bracket). We end up with a situation where each time a new context is added, a new weak pointer is created. If the thread is long-lived then this can lead to a slow space leak.

I noticed this in a context where we had a long running job runner thread, which would acquire a new root span whenever it ran a job, and detached it afterwards.

I have just disabled the finalizer creation on our project for now, but I'd be interested to hear if you have a preferred solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions