Skip to content

[FEA]: Add a release() method to cuda.core.Buffer to side-step the Python garbage collector #567

@leofang

Description

@leofang

Is this a duplicate?

Area

cuda.core

Is your feature request related to a problem? Please describe.

@realarnavgoel brought up this issue offline that we currently have a fallback weak finalizer

weakref.finalize(buffer_obj, self.close)

in case users forget to explicitly call .close() to free the memory. This could interfere with projects such as nvmath-python and nvSHMEM who require explicit control over the buffer lifetime and deallocation timing.

Describe the solution you'd like

We discussed offline and came up with this proposal that we'll add a .release() method to the buffer object. The idea is that if it is called, the weak finalizer will be unregistered, so that the only way to free the buffer is to call .close() explicitly later.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    cuda.coreEverything related to the cuda.core modulefeatureNew feature or request

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions