Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
avoid accessing self's Python attributes in dealloc
  • Loading branch information
leofang committed Oct 8, 2025
commit ae55db667cd87f991b98f589e81a339a371d6d73
11 changes: 1 addition & 10 deletions cuda_core/cuda/core/experimental/_memory.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ class DeviceMemoryResourceAttributes:
# This enables buffer serialization, as buffers can reduce to a pair
# of comprising the memory resource UUID (the key into this registry)
# and the serialized buffer descriptor.
_ipc_registry = {}
cdef object _ipc_registry = weakref.WeakValueDictionary()


cdef class DeviceMemoryResource(MemoryResource):
Expand Down Expand Up @@ -759,8 +759,6 @@ cdef class DeviceMemoryResource(MemoryResource):
with nogil:
HANDLE_RETURN(cydriver.cuMemPoolDestroy(self._mempool_handle))
finally:
if self.is_mapped:
self.unregister()
self._dev_id = cydriver.CU_DEVICE_INVALID
self._mempool_handle = NULL
self._attributes = None
Expand Down Expand Up @@ -806,13 +804,6 @@ cdef class DeviceMemoryResource(MemoryResource):
self._uuid = uuid
return self

def unregister(self):
"""Unregister this mapped memory resource."""
assert self.is_mapped
if _ipc_registry is not None: # can occur during shutdown catastrophe
with contextlib.suppress(KeyError):
del _ipc_registry[self.uuid]

@property
def uuid(self) -> Optional[uuid.UUID]:
"""
Expand Down