Skip to content

Promises can result in hard to free memory when rejected or fulfilled with complex objects #106

@patrys

Description

@patrys

I don't have a simple reproduction as our codebase is stuck with graphql-core 2.x (which is a legacy branch), but we often see the garbage collector report reference cycles created by orphaned Promise objects that reference a stack trace that in turn points back to a local scope that contains the Promise.

Adding a simple destructor gets rid of this problem and allows objects to be freed without relying on the garbage collection cycles:

class Promise:
    ...

    def __del__(self) -> None:
        self._fulfillment_handler0 = None
        self._rejection_handler0 = None
        self._promise0 = None
        self._traceback = None

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