From a01154e3fdc481d2c0576f9227dba68f13f28251 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 3 Oct 2020 19:45:42 +0200 Subject: [PATCH] crypto: fix KeyObject garbage collection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These objects don’t hold any resources on the event loop, so they should be weak objects that can be garbage collected when nothing refers to them anymore. PR-URL: https://github.com/nodejs/node/pull/35481 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- src/node_crypto.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node_crypto.h b/src/node_crypto.h index 8f781035602b07..bef98b3e244d9e 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -519,7 +519,9 @@ class NativeKeyObject : public BaseObject { v8::Local wrap, const std::shared_ptr& handle_data) : BaseObject(env, wrap), - handle_data_(handle_data) {} + handle_data_(handle_data) { + MakeWeak(); + } std::shared_ptr handle_data_; };