Skip to content

Commit

Permalink
crypto: fix KeyObject garbage collection
Browse files Browse the repository at this point in the history
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: #35481
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
addaleax committed Oct 3, 2020
1 parent 35b17d9 commit f5c7aa0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/node_crypto.h
Expand Up @@ -519,7 +519,9 @@ class NativeKeyObject : public BaseObject {
v8::Local<v8::Object> wrap,
const std::shared_ptr<KeyObjectData>& handle_data)
: BaseObject(env, wrap),
handle_data_(handle_data) {}
handle_data_(handle_data) {
MakeWeak();
}

std::shared_ptr<KeyObjectData> handle_data_;
};
Expand Down

0 comments on commit f5c7aa0

Please sign in to comment.