Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
communication_ipc
提交
19a39a67
C
communication_ipc
项目概览
OpenHarmony
/
communication_ipc
大约 1 年 前同步成功
通知
20
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
communication_ipc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
19a39a67
编写于
4月 18, 2023
作者:
马
马根堂
提交者:
Gitee
4月 18, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remoteobject mem free
Signed-off-by:
N
马根堂
<
magentang4@huawei.com
>
上级
84e7dd03
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
0 addition
and
11 deletion
+0
-11
ipc/native/src/core/source/ipc_object_proxy.cpp
ipc/native/src/core/source/ipc_object_proxy.cpp
+0
-1
ipc/native/src/napi_common/source/napi_remote_object.cpp
ipc/native/src/napi_common/source/napi_remote_object.cpp
+0
-7
ipc/native/src/napi_common/source/napi_remote_object_holder.cpp
...tive/src/napi_common/source/napi_remote_object_holder.cpp
+0
-3
未找到文件。
ipc/native/src/core/source/ipc_object_proxy.cpp
浏览文件 @
19a39a67
...
@@ -55,7 +55,6 @@ static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "IPCObjec
...
@@ -55,7 +55,6 @@ static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_IPC, "IPCObjec
IPCObjectProxy
::
IPCObjectProxy
(
int
handle
,
std
::
u16string
descriptor
,
int
proto
)
IPCObjectProxy
::
IPCObjectProxy
(
int
handle
,
std
::
u16string
descriptor
,
int
proto
)
:
IRemoteObject
(
std
::
move
(
descriptor
)),
handle_
(
handle
),
proto_
(
proto
),
isFinishInit_
(
false
),
isRemoteDead_
(
false
)
:
IRemoteObject
(
std
::
move
(
descriptor
)),
handle_
(
handle
),
proto_
(
proto
),
isFinishInit_
(
false
),
isRemoteDead_
(
false
)
{
{
ZLOGD
(
LABEL
,
"[mem_free]IPCObjectProxy create"
);
ExtendObjectLifetime
();
ExtendObjectLifetime
();
}
}
...
...
ipc/native/src/napi_common/source/napi_remote_object.cpp
浏览文件 @
19a39a67
...
@@ -53,7 +53,6 @@ inline T *ConvertNativeValueTo(NativeValue *value)
...
@@ -53,7 +53,6 @@ inline T *ConvertNativeValueTo(NativeValue *value)
static
void
RemoteObjectHolderFinalizeCb
(
napi_env
env
,
void
*
data
,
void
*
hint
)
static
void
RemoteObjectHolderFinalizeCb
(
napi_env
env
,
void
*
data
,
void
*
hint
)
{
{
ZLOGI
(
LOG_LABEL
,
"[mem_free]RemoteObjectHolderFinalizeCb inter"
);
NAPIRemoteObjectHolder
*
holder
=
reinterpret_cast
<
NAPIRemoteObjectHolder
*>
(
data
);
NAPIRemoteObjectHolder
*
holder
=
reinterpret_cast
<
NAPIRemoteObjectHolder
*>
(
data
);
if
(
holder
==
nullptr
)
{
if
(
holder
==
nullptr
)
{
ZLOGW
(
LOG_LABEL
,
"RemoteObjectHolderFinalizeCb null holder"
);
ZLOGW
(
LOG_LABEL
,
"RemoteObjectHolderFinalizeCb null holder"
);
...
@@ -62,14 +61,12 @@ static void RemoteObjectHolderFinalizeCb(napi_env env, void *data, void *hint)
...
@@ -62,14 +61,12 @@ static void RemoteObjectHolderFinalizeCb(napi_env env, void *data, void *hint)
holder
->
Lock
();
holder
->
Lock
();
int32_t
curAttachCount
=
holder
->
DecAttachCount
();
int32_t
curAttachCount
=
holder
->
DecAttachCount
();
if
(
curAttachCount
==
0
)
{
if
(
curAttachCount
==
0
)
{
ZLOGI
(
LOG_LABEL
,
"[mem_free]RemoteObjectHolderFinalizeCb release holder"
);
delete
holder
;
delete
holder
;
}
}
}
}
static
void
*
RemoteObjectDetachCb
(
NativeEngine
*
engine
,
void
*
value
,
void
*
hint
)
static
void
*
RemoteObjectDetachCb
(
NativeEngine
*
engine
,
void
*
value
,
void
*
hint
)
{
{
ZLOGI
(
LOG_LABEL
,
"[mem_free]RemoteObjectDetachCb inter"
);
(
void
)
engine
;
(
void
)
engine
;
(
void
)
hint
;
(
void
)
hint
;
return
value
;
return
value
;
...
@@ -77,7 +74,6 @@ static void *RemoteObjectDetachCb(NativeEngine *engine, void *value, void *hint)
...
@@ -77,7 +74,6 @@ static void *RemoteObjectDetachCb(NativeEngine *engine, void *value, void *hint)
static
NativeValue
*
RemoteObjectAttachCb
(
NativeEngine
*
engine
,
void
*
value
,
void
*
hint
)
static
NativeValue
*
RemoteObjectAttachCb
(
NativeEngine
*
engine
,
void
*
value
,
void
*
hint
)
{
{
ZLOGI
(
LOG_LABEL
,
"[mem_free]RemoteObjectAttachCb inter"
);
(
void
)
hint
;
(
void
)
hint
;
NAPIRemoteObjectHolder
*
holder
=
reinterpret_cast
<
NAPIRemoteObjectHolder
*>
(
value
);
NAPIRemoteObjectHolder
*
holder
=
reinterpret_cast
<
NAPIRemoteObjectHolder
*>
(
value
);
if
(
holder
==
nullptr
)
{
if
(
holder
==
nullptr
)
{
...
@@ -119,7 +115,6 @@ static NativeValue *RemoteObjectAttachCb(NativeEngine *engine, void *value, void
...
@@ -119,7 +115,6 @@ static NativeValue *RemoteObjectAttachCb(NativeEngine *engine, void *value, void
napi_value
RemoteObject_JS_Constructor
(
napi_env
env
,
napi_callback_info
info
)
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
// new napi remote object
size_t
argc
=
2
;
size_t
argc
=
2
;
size_t
expectedArgc
=
1
;
size_t
expectedArgc
=
1
;
...
@@ -160,7 +155,6 @@ napi_value RemoteObject_JS_Constructor(napi_env env, napi_callback_info info)
...
@@ -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
)
NAPIRemoteObject
::
NAPIRemoteObject
(
napi_env
env
,
napi_value
thisVar
,
const
std
::
u16string
&
descriptor
)
:
IPCObjectStub
(
descriptor
)
:
IPCObjectStub
(
descriptor
)
{
{
ZLOGI
(
LOG_LABEL
,
"[mem_free]NAPIRemoteObject create"
);
env_
=
env
;
env_
=
env
;
thisVar_
=
thisVar
;
thisVar_
=
thisVar
;
napi_create_reference
(
env
,
thisVar_
,
1
,
&
thisVarRef_
);
napi_create_reference
(
env
,
thisVar_
,
1
,
&
thisVarRef_
);
...
@@ -169,7 +163,6 @@ NAPIRemoteObject::NAPIRemoteObject(napi_env env, napi_value thisVar, const std::
...
@@ -169,7 +163,6 @@ NAPIRemoteObject::NAPIRemoteObject(napi_env env, napi_value thisVar, const std::
NAPIRemoteObject
::~
NAPIRemoteObject
()
NAPIRemoteObject
::~
NAPIRemoteObject
()
{
{
ZLOGI
(
LOG_LABEL
,
"[mem_free]NAPIRemoteObject Destructor"
);
if
(
thisVarRef_
!=
nullptr
)
{
if
(
thisVarRef_
!=
nullptr
)
{
napi_status
status
=
napi_delete_reference
(
env_
,
thisVarRef_
);
napi_status
status
=
napi_delete_reference
(
env_
,
thisVarRef_
);
NAPI_ASSERT_RETURN_VOID
(
env_
,
status
==
napi_ok
,
"failed to delete ref to js RemoteObject"
);
NAPI_ASSERT_RETURN_VOID
(
env_
,
status
==
napi_ok
,
"failed to delete ref to js RemoteObject"
);
...
...
ipc/native/src/napi_common/source/napi_remote_object_holder.cpp
浏览文件 @
19a39a67
...
@@ -25,12 +25,10 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, LOG_ID_IPC,
...
@@ -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
)
NAPIRemoteObjectHolder
::
NAPIRemoteObjectHolder
(
napi_env
env
,
const
std
::
u16string
&
descriptor
)
:
env_
(
env
),
descriptor_
(
descriptor
),
cachedObject_
(
nullptr
),
localInterfaceRef_
(
nullptr
),
attachCount_
(
1
)
:
env_
(
env
),
descriptor_
(
descriptor
),
cachedObject_
(
nullptr
),
localInterfaceRef_
(
nullptr
),
attachCount_
(
1
)
{
{
ZLOGI
(
LOG_LABEL
,
"[mem_free]NAPIRemoteObjectHolder create"
);
}
}
NAPIRemoteObjectHolder
::~
NAPIRemoteObjectHolder
()
NAPIRemoteObjectHolder
::~
NAPIRemoteObjectHolder
()
{
{
ZLOGI
(
LOG_LABEL
,
"[mem_free]NAPIRemoteObjectHolder free"
);
// free the reference of object.
// free the reference of object.
cachedObject_
=
nullptr
;
cachedObject_
=
nullptr
;
if
(
localInterfaceRef_
!=
nullptr
)
{
if
(
localInterfaceRef_
!=
nullptr
)
{
...
@@ -40,7 +38,6 @@ NAPIRemoteObjectHolder::~NAPIRemoteObjectHolder()
...
@@ -40,7 +38,6 @@ NAPIRemoteObjectHolder::~NAPIRemoteObjectHolder()
sptr
<
NAPIRemoteObject
>
NAPIRemoteObjectHolder
::
Get
(
napi_value
jsRemoteObject
)
sptr
<
NAPIRemoteObject
>
NAPIRemoteObjectHolder
::
Get
(
napi_value
jsRemoteObject
)
{
{
ZLOGI
(
LOG_LABEL
,
"[mem_free]NAPIRemoteObjectHolder Get"
);
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
mutex_
);
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
mutex_
);
// grab an strong reference to the object,
// grab an strong reference to the object,
// so it will not be freed util this reference released.
// 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录