未验证 提交 19a39a67 编写于 作者: 马根堂 提交者: Gitee

remoteobject mem free

Signed-off-by: N马根堂 <magentang4@huawei.com>
上级 84e7dd03
......@@ -55,7 +55,6 @@ static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "IPCObjec
IPCObjectProxy::IPCObjectProxy(int handle, std::u16string descriptor, int proto)
: IRemoteObject(std::move(descriptor)), handle_(handle), proto_(proto), isFinishInit_(false), isRemoteDead_(false)
{
ZLOGD(LABEL, "[mem_free]IPCObjectProxy create");
ExtendObjectLifetime();
}
......
......@@ -53,7 +53,6 @@ inline T *ConvertNativeValueTo(NativeValue *value)
static void RemoteObjectHolderFinalizeCb(napi_env env, void *data, void *hint)
{
ZLOGI(LOG_LABEL, "[mem_free]RemoteObjectHolderFinalizeCb inter");
NAPIRemoteObjectHolder *holder = reinterpret_cast<NAPIRemoteObjectHolder *>(data);
if (holder == nullptr) {
ZLOGW(LOG_LABEL, "RemoteObjectHolderFinalizeCb null holder");
......@@ -62,14 +61,12 @@ static void RemoteObjectHolderFinalizeCb(napi_env env, void *data, void *hint)
holder->Lock();
int32_t curAttachCount = holder->DecAttachCount();
if (curAttachCount == 0) {
ZLOGI(LOG_LABEL, "[mem_free]RemoteObjectHolderFinalizeCb release holder");
delete holder;
}
}
static void *RemoteObjectDetachCb(NativeEngine *engine, void *value, void *hint)
{
ZLOGI(LOG_LABEL, "[mem_free]RemoteObjectDetachCb inter");
(void)engine;
(void)hint;
return value;
......@@ -77,7 +74,6 @@ static void *RemoteObjectDetachCb(NativeEngine *engine, void *value, void *hint)
static NativeValue *RemoteObjectAttachCb(NativeEngine *engine, void *value, void *hint)
{
ZLOGI(LOG_LABEL, "[mem_free]RemoteObjectAttachCb inter");
(void)hint;
NAPIRemoteObjectHolder *holder = reinterpret_cast<NAPIRemoteObjectHolder *>(value);
if (holder == nullptr) {
......@@ -119,7 +115,6 @@ static NativeValue *RemoteObjectAttachCb(NativeEngine *engine, void *value, void
napi_value RemoteObject_JS_Constructor(napi_env env, napi_callback_info info)
{
ZLOGI(LOG_LABEL, "[mem_free]RemoteObject_JS_Constructor inter");
// new napi remote object
size_t argc = 2;
size_t expectedArgc = 1;
......@@ -160,7 +155,6 @@ napi_value RemoteObject_JS_Constructor(napi_env env, napi_callback_info info)
NAPIRemoteObject::NAPIRemoteObject(napi_env env, napi_value thisVar, const std::u16string &descriptor)
: IPCObjectStub(descriptor)
{
ZLOGI(LOG_LABEL, "[mem_free]NAPIRemoteObject create");
env_ = env;
thisVar_ = thisVar;
napi_create_reference(env, thisVar_, 1, &thisVarRef_);
......@@ -169,7 +163,6 @@ NAPIRemoteObject::NAPIRemoteObject(napi_env env, napi_value thisVar, const std::
NAPIRemoteObject::~NAPIRemoteObject()
{
ZLOGI(LOG_LABEL, "[mem_free]NAPIRemoteObject Destructor");
if (thisVarRef_ != nullptr) {
napi_status status = napi_delete_reference(env_, thisVarRef_);
NAPI_ASSERT_RETURN_VOID(env_, status == napi_ok, "failed to delete ref to js RemoteObject");
......
......@@ -25,12 +25,10 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, LOG_ID_IPC,
NAPIRemoteObjectHolder::NAPIRemoteObjectHolder(napi_env env, const std::u16string &descriptor)
: env_(env), descriptor_(descriptor), cachedObject_(nullptr), localInterfaceRef_(nullptr), attachCount_(1)
{
ZLOGI(LOG_LABEL, "[mem_free]NAPIRemoteObjectHolder create");
}
NAPIRemoteObjectHolder::~NAPIRemoteObjectHolder()
{
ZLOGI(LOG_LABEL, "[mem_free]NAPIRemoteObjectHolder free");
// free the reference of object.
cachedObject_ = nullptr;
if (localInterfaceRef_ != nullptr) {
......@@ -40,7 +38,6 @@ NAPIRemoteObjectHolder::~NAPIRemoteObjectHolder()
sptr<NAPIRemoteObject> NAPIRemoteObjectHolder::Get(napi_value jsRemoteObject)
{
ZLOGI(LOG_LABEL, "[mem_free]NAPIRemoteObjectHolder Get");
std::lock_guard<std::mutex> lockGuard(mutex_);
// grab an strong reference to the object,
// so it will not be freed util this reference released.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册