Skip to content

fix: memory leak when overwriting cached DBus property values#562

Open
yixinshark wants to merge 1 commit intolinuxdeepin:masterfrom
yixinshark:fix-memoryLeak
Open

fix: memory leak when overwriting cached DBus property values#562
yixinshark wants to merge 1 commit intolinuxdeepin:masterfrom
yixinshark:fix-memoryLeak

Conversation

@yixinshark
Copy link
Copy Markdown

In internalPropGet, QMetaType::construct is called on propertyPtr to copy the latest value from a DBus reply, but the old object at that address is never destructed. When the property type contains heap-allocated members (such as QByteArray pixels inside DBusImageList), this leak accumulates on every property read from the StatusNotifierItem interface (iconPixmap, attentionIconPixmap, overlayIconPixmap, ToolTip etc.).

Add destruct before construct to properly release the previous value. This reduces application-tray RSS growth from ~23 KB/s to ~3 KB/s.

internalPropGet 中每次 DBus 属性读取都通过 QMetaType::construct 将新值 原地复制到 propertyPtr,但旧对象未析构。对于包含堆内存成员的类型(如
DBusImageList 中的 QByteArray pixels),每次读取均导致旧数据泄漏。在 construct 前添加 destruct 释放旧值,application-tray 进程 RSS 增长从 约 23 KB/s 降至约 3 KB/s。

Log: fix: memory leak when overwriting cached DBus property values
Pms: BUG-359161
Change-Id: I80a2ed404b87bb87ce66fb3361ff7eb640b6c9fb

In internalPropGet, QMetaType::construct is called on propertyPtr to copy
the latest value from a DBus reply, but the old object at that address is
never destructed. When the property type contains heap-allocated members
(such as QByteArray pixels inside DBusImageList), this leak accumulates
on every property read from the StatusNotifierItem interface (iconPixmap,
attentionIconPixmap, overlayIconPixmap, ToolTip etc.).

Add destruct before construct to properly release the previous value.
This reduces application-tray RSS growth from ~23 KB/s to ~3 KB/s.

internalPropGet 中每次 DBus 属性读取都通过 QMetaType::construct 将新值
原地复制到 propertyPtr,但旧对象未析构。对于包含堆内存成员的类型(如
DBusImageList 中的 QByteArray pixels),每次读取均导致旧数据泄漏。在
construct 前添加 destruct 释放旧值,application-tray 进程 RSS 增长从
约 23 KB/s 降至约 3 KB/s。

Log: fix: memory leak when overwriting cached DBus property values
Pms: BUG-359161
Change-Id: I80a2ed404b87bb87ce66fb3361ff7eb640b6c9fb
@deepin-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yixinshark

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants