From e2aaef8b6c19a8d5d764ce8d40f3668e14f75e7d Mon Sep 17 00:00:00 2001 From: ed-tsn Date: Fri, 3 Jul 2026 09:08:47 +0200 Subject: [PATCH] Fix memory leak in _DynamicCapabilityClient._send_helper() (#398) The heap-allocated Request object was never freed after send(). Each RPC call leaked ~72 bytes, growing linearly with usage. Added del request after request.send() to free the Request once the RemotePromise has been constructed. --- capnp/lib/capnp.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/capnp/lib/capnp.pyx b/capnp/lib/capnp.pyx index 538c46f..b5347f4 100644 --- a/capnp/lib/capnp.pyx +++ b/capnp/lib/capnp.pyx @@ -2320,7 +2320,9 @@ cdef class _DynamicCapabilityClient: self._set_fields(request, name, args, kwargs) - return _RemotePromise()._init(request.send(), self) + cdef _RemotePromise result = _RemotePromise()._init(request.send(), self) + del request + return result cpdef _request_helper(self, name, firstSegmentWordSize, args, kwargs): # if word_count is None: