diff options
author | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-11-12 23:23:19 +0400 |
---|---|---|
committer | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-11-12 23:23:19 +0400 |
commit | 16934d9210546bf19d4af8d98652aa5d636ce693 (patch) | |
tree | 1905f35f84db3ab6dc82bc6bff5dac2b835817aa /src/handle_wrap.cc | |
parent | ac799ba0afa9731e281bf23886d1a3f5adec1784 (diff) |
src: add HandleScope in HandleWrap::OnClose
Fixes a 4 byte leak on handles closing. AKA The Walmart leak.
MakeCallback doesn't have a HandleScope. That means the callers scope
will retain ownership of created handles from MakeCallback and related.
There is by default a wrapping HandleScope before uv_run, if the caller
doesn't have a HandleScope on the stack the global will take ownership
which won't be reaped until the uv loop exits.
If a uv callback is fired, and there is no enclosing HandleScope in the
cb, you will appear to leak 4-bytes for every invocation. Take heed.
cc @hueniverse
Diffstat (limited to 'src/handle_wrap.cc')
-rw-r--r-- | src/handle_wrap.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc index a63421bc299..c70b786418b 100644 --- a/src/handle_wrap.cc +++ b/src/handle_wrap.cc @@ -134,6 +134,8 @@ HandleWrap::~HandleWrap() { void HandleWrap::OnClose(uv_handle_t* handle) { + HandleScope scope; + HandleWrap* wrap = static_cast<HandleWrap*>(handle->data); // The wrap object should still be there. |