BewareMyPower commented on code in PR #412:
URL:
https://github.com/apache/pulsar-client-node/pull/412#discussion_r2079116829
##########
src/Client.cc:
##########
@@ -138,7 +138,9 @@ Client::Client(const Napi::CallbackInfo &info) :
Napi::ObjectWrap<Client>(info)
if (clientConfig.Has(CFG_AUTH) && clientConfig.Get(CFG_AUTH).IsObject()) {
Napi::Object obj = clientConfig.Get(CFG_AUTH).ToObject();
if (obj.Has(CFG_AUTH_PROP) && obj.Get(CFG_AUTH_PROP).IsObject()) {
- Authentication *auth =
Authentication::Unwrap(obj.Get(CFG_AUTH_PROP).ToObject());
+ this->authRef_ =
Napi::Persistent(obj.Get(CFG_AUTH_PROP).As<Napi::Object>());
+ this->authRef_.SuppressDestruct();
Review Comment:
`SuppressDestruct()` suppresses the destruction of `authRef_`, which is
held by the `Client` instance. Could you try removing this call?
This method is used here:
https://github.com/apache/pulsar-client-node/blob/b79ead00441779a348e921f1aa638f1e2dce35c9/src/Client.cc#L88
However, `constructor` is a static variable, whose lifetime is the same with
the whole program. But here `authRef_`'s lifetime is the same with the
`Client`. Suppressing the destruction of `authRef_` could cause memory leak.
<img width="659" alt="image"
src="https://github.com/user-attachments/assets/3e7cfa5c-77a1-4e0a-b3f5-bdb4d73ca282"
/>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]