From dccb69a21afc759e8827a5293ee8648d3ba354b0 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 5 Mar 2015 20:26:12 -0500 Subject: [PATCH] js_stream: fix leak of instances Don't forget to call `MakeWeak` to ensure that instance objects are garbage collectable. PR-URL: https://github.com/iojs/io.js/pull/1078 Reviewed-By: Ben Noordhuis --- src/js_stream.cc | 1 + src/js_stream.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/js_stream.cc b/src/js_stream.cc index 21f5ce07ac08b3..7fcdfd9a94d9fd 100644 --- a/src/js_stream.cc +++ b/src/js_stream.cc @@ -26,6 +26,7 @@ JSStream::JSStream(Environment* env, Handle obj, AsyncWrap* parent) : StreamBase(env), AsyncWrap(env, obj, AsyncWrap::PROVIDER_JSSTREAM, parent) { node::Wrap(obj, this); + MakeWeak(this); } diff --git a/src/js_stream.h b/src/js_stream.h index 8e2ff13258b219..6bc763b36e2bd1 100644 --- a/src/js_stream.h +++ b/src/js_stream.h @@ -14,6 +14,8 @@ class JSStream : public StreamBase, public AsyncWrap { v8::Handle unused, v8::Handle context); + ~JSStream(); + void* Cast() override; bool IsAlive() override; bool IsClosing() override; @@ -28,7 +30,6 @@ class JSStream : public StreamBase, public AsyncWrap { protected: JSStream(Environment* env, v8::Handle obj, AsyncWrap* parent); - ~JSStream(); AsyncWrap* GetAsyncWrap() override;