Commit 27d015c7 authored by Haijun Zhu's avatar Haijun Zhu Committed by Facebook Github Bot

Explicitly destroy c++ IOBuf from cython IOBuf

Summary: This seems to not happen reliably and causes rss to grow. The `__dealloc__` cannot fix it completely, although I verified it is called. So calling it explicitly seems to guarantee it to happen.

Reviewed By: yfeldblum

Differential Revision: D20206887

fbshipit-source-id: 6285a8e8943a53d20714e54efd3220a545010102
parent 4e969a2d
...@@ -64,6 +64,7 @@ cdef class IOBuf: ...@@ -64,6 +64,7 @@ cdef class IOBuf:
cdef Py_ssize_t strides[1] cdef Py_ssize_t strides[1]
@staticmethod @staticmethod
cdef IOBuf create(cIOBuf* this, object parent) cdef IOBuf create(cIOBuf* this, object parent)
cdef void cleanup(self)
cdef unique_ptr[cIOBuf] c_clone(self) cdef unique_ptr[cIOBuf] c_clone(self)
cdef unique_ptr[cIOBuf] from_python_buffer(memoryview view) cdef unique_ptr[cIOBuf] from_python_buffer(memoryview view)
......
...@@ -54,6 +54,9 @@ cdef class IOBuf: ...@@ -54,6 +54,9 @@ cdef class IOBuf:
self._hash = None self._hash = None
__cache[(<unsigned long>self._this, id(self))] = self __cache[(<unsigned long>self._this, id(self))] = self
def __dealloc__(self):
self._ours.reset()
@staticmethod @staticmethod
cdef IOBuf create(cIOBuf* this, object parent): cdef IOBuf create(cIOBuf* this, object parent):
key = (<unsigned long>this, id(parent)) key = (<unsigned long>this, id(parent))
...@@ -65,6 +68,9 @@ cdef class IOBuf: ...@@ -65,6 +68,9 @@ cdef class IOBuf:
__cache[key] = inst __cache[key] = inst
return inst return inst
cdef void cleanup(self):
self._ours.reset()
cdef unique_ptr[cIOBuf] c_clone(self): cdef unique_ptr[cIOBuf] c_clone(self):
return move(self._this.clone()) return move(self._this.clone())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment