Skip to content

fix: split system-wide memory pressure from per-process RSS in SystemSummary (#13)#24

Merged
ShadyUnderLight merged 1 commit intomainfrom
fix/issue13-memory口径分离
Apr 20, 2026

Hidden character warning

The head ref may contain hidden characters: "fix/issue13-memory\u53e3\u5f84\u5206\u79bb"
Merged

fix: split system-wide memory pressure from per-process RSS in SystemSummary (#13)#24
ShadyUnderLight merged 1 commit intomainfrom
fix/issue13-memory口径分离

Conversation

@ShadyUnderLight
Copy link
Copy Markdown
Owner

问题

SystemMetricsProvider.currentUsedMemory 计算的是 system-wide memory pages(active + inactive + wired + compressor),与 Activity Monitor 的"App Memory / Memory Used"完全不是一个概念。用户看到"70% 内存占用"但 Activity Monitor 显示完全不同,会感到困惑。

解决方案

  1. SystemSummary 增加 appMemoryUsedBytes: UInt64 字段,通过 proc_pidinfo 获取当前 app 的 RSS
  2. systemMemoryUsedBytes(原 memoryUsedBytes)保留为系统级 memory pressure 计算口径
  3. memoryPressurePercent 继续使用 systemMemoryUsedBytes,与旧行为完全一致
  4. UI label summary.ram 改为 "RAM (System-wide)" / "内存 (系统级)",与 Activity Monitor 口径区分清晰
  5. appMemoryUsedBytes 字段已就位,后续如需在 Settings 加切换或 SummaryCard 加额外标注,可直接复用

行为变化

字段 说明 用途
systemMemoryUsedBytes system-wide pages(原有逻辑) menu bar / SummaryCard / 百分比计算
appMemoryUsedBytes 当前 app RSS via proc_pidinfo 已就位,后续可扩展
memoryPressurePercent 不变,使用 systemMemoryUsedBytes 不影响现有 UI 计算

Closes #13

…Summary (#13)

- SystemSummary now carries both systemMemoryUsedBytes (active+inactive+wired+compressor pages)
  and appMemoryUsedBytes (current app RSS via proc_pidinfo)
- memoryPressurePercent uses systemMemoryUsedBytes (unchanged calculation)
- UI labels for summary.ram now read 'RAM (System-wide)' / '内存 (系统级)'
- Views.swift and MonitorViewModel.swift updated to use systemMemoryUsedBytes
@ShadyUnderLight ShadyUnderLight merged commit aaf68da into main Apr 20, 2026
2 checks passed
@ShadyUnderLight ShadyUnderLight deleted the fix/issue13-memory口径分离 branch April 20, 2026 08:36
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.

[Bug] memoryPressurePercent 与 shortMemoryString 计算口径不一致,混淆 system-wide memory pressure 和进程 RSS

1 participant