Skip to content

Commit

Permalink
Merge pull request #4015 from leofang/managed_free
Browse files Browse the repository at this point in the history
Fix managed memory leak
  • Loading branch information
kmaehashi committed Sep 29, 2020
2 parents 5d13d79 + 91f824d commit 9f05d49
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cupy/cuda/memory.pyx
Expand Up @@ -175,6 +175,11 @@ cdef class ManagedMemory(BaseMemory):
"""
runtime.memAdvise(self.ptr, self.size, advise, device.id)

def __dealloc__(self):
if self.ptr:
syncdetect._declare_synchronize()
runtime.free(self.ptr)


cdef set _peer_access_checked = set()

Expand Down Expand Up @@ -1360,9 +1365,9 @@ ctypedef void*(*malloc_func_type)(void*, size_t, int)
ctypedef void(*free_func_type)(void*, void*, int)


cdef size_t _call_malloc(
cdef intptr_t _call_malloc(
intptr_t param, intptr_t malloc_func, Py_ssize_t size, int device_id):
return <size_t>(
return <intptr_t>(
(<malloc_func_type>malloc_func)(<void*>param, size, device_id))


Expand Down

0 comments on commit 9f05d49

Please sign in to comment.