fix(diag): 私有内存读数做防守(Windows 出现 private>工作集 的错误值时不展示)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 34s

This commit is contained in:
qiqi committed 2026-12-02 16:58:15 +08:00
1 parent 1677f86129
commit 499f16a2df
2 files changed
+7 -2

No files matched your search

+6 -1
View File
@@ -170,7 +170,12 @@
return el('div', null,
el('div', { className: 'iwb-section-sub' }, '内存拆解(分进程' + (wsKind ? '工作集' : 'footprint') + ',合计 ' + (bd.totalMB || 0) + 'MB' + (wvMB ? (' · WebView2 ' + wvMB + 'MB') : '') + ')'),
procs.length ? el('div', { className: 'iwb-diag-list' }, procs.map((p, i) => el('div', { key: 'mp' + i, className: 'iwb-diag-item' },
el('div', { className: 'iwb-diag-head' }, p.role + (p.pid ? (' #' + p.pid) : '') + ' · ' + p.footprintMB + 'MB' + (p.privMB != null ? ('(私有 ' + p.privMB + 'MB)') : '')),
(() => {
// 2026-12-02:Windows 实测出现过「私有 1244MB > 工作集 154MB」的读数(Rust app_memory_breakdown 的
// PrivateUsage 口径在该机不对)。这里做防守:明显不可能的值不展示,避免用户误判成 1.2GB 占用。
const priv = (typeof p.privMB === 'number' && p.privMB >= 0 && p.privMB <= (Number(p.footprintMB) || 0) * 1.5) ? p.privMB : null
return el('div', { className: 'iwb-diag-head' }, p.role + (p.pid ? (' #' + p.pid) : '') + ' · ' + p.footprintMB + 'MB' + (priv != null ? ('(私有 ' + priv + 'MB)') : ''))
})(),
(p.top && p.top.length) ? el('div', { className: 'iwb-diag-extra' }, p.top.slice(0, 3).map((c) => c.cat + ' ' + c.dirtyMB + 'MB').join(' · ')) : null,
))) : el('div', { className: 'iwb-hint' }, '仅桌面端可读取'),
el('div', { className: 'iwb-hint' }, wsKind