fix: split system-wide memory pressure from per-process RSS in SystemSummary (#13)#24
Merged
ShadyUnderLight merged 1 commit intomainfrom Apr 20, 2026
Hidden character warning
The head ref may contain hidden characters: "fix/issue13-memory\u53e3\u5f84\u5206\u79bb"
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
SystemMetricsProvider.currentUsedMemory计算的是 system-wide memory pages(active + inactive + wired + compressor),与 Activity Monitor 的"App Memory / Memory Used"完全不是一个概念。用户看到"70% 内存占用"但 Activity Monitor 显示完全不同,会感到困惑。解决方案
SystemSummary增加appMemoryUsedBytes: UInt64字段,通过proc_pidinfo获取当前 app 的 RSSsystemMemoryUsedBytes(原memoryUsedBytes)保留为系统级 memory pressure 计算口径memoryPressurePercent继续使用systemMemoryUsedBytes,与旧行为完全一致summary.ram改为 "RAM (System-wide)" / "内存 (系统级)",与 Activity Monitor 口径区分清晰appMemoryUsedBytes字段已就位,后续如需在 Settings 加切换或 SummaryCard 加额外标注,可直接复用行为变化
systemMemoryUsedBytesappMemoryUsedBytesproc_pidinfomemoryPressurePercentsystemMemoryUsedBytesCloses #13