Skip to content

fix: improve RAM usage calculation and top processes#3160

Open
agentHits wants to merge 1 commit intoexelban:masterfrom
agentHits:fix/ram-usage-top-processes
Open

fix: improve RAM usage calculation and top processes#3160
agentHits wants to merge 1 commit intoexelban:masterfrom
agentHits:fix/ram-usage-top-processes

Conversation

@agentHits
Copy link
Copy Markdown

@agentHits agentHits commented Apr 21, 2026

image

This PR fixes two RAM-related issues:

  • the used memory value is now closer to Activity Monitor
  • the top processes list now uses more accurate RAM data and preserves real process names in non-combined mode

Changes

  • adjusted RAM breakdown calculation in Modules/RAM/readers.swift
  • switched top process memory usage to proc_pid_rusage(..., ri_phys_footprint)
  • improved process name resolution for helper/web content processes
  • refreshed the RAM process list immediately after RAM settings changes

Tests

  • updated Tests/RAM.swift
  • verified with:
xcodebuild test \
  -project Stats.xcodeproj \
  -scheme Stats \
  -destination 'platform=macOS' \
  -only-testing:Tests/RAM \
  CODE_SIGNING_ALLOWED=NO \
  CODE_SIGNING_REQUIRED=NO \
  CODE_SIGN_IDENTITY=''

This PR fixes two RAM-related issues:

- the used memory value is now closer to Activity Monitor
- the top processes list now uses more accurate RAM data and preserves real process names in non-combined mode

### Changes

- adjusted RAM breakdown calculation in `Modules/RAM/readers.swift`
- switched top process memory usage to `proc_pid_rusage(..., ri_phys_footprint)`
- improved process name resolution for helper/web content processes
- refreshed the RAM process list immediately after RAM settings changes

### Tests

- updated `Tests/RAM.swift`
- verified with:

```bash
xcodebuild test \
  -project Stats.xcodeproj \
  -scheme Stats \
  -destination 'platform=macOS' \
  -only-testing:Tests/RAM \
  CODE_SIGNING_ALLOWED=NO \
  CODE_SIGNING_REQUIRED=NO \
  CODE_SIGN_IDENTITY=''
Comment thread Modules/RAM/main.swift

self.settingsView.callback = { [weak self] in
self?.usageReader?.read()
self?.processReader?.read()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why open settings trigger process read?

Comment thread Modules/RAM/readers.swift
import Darwin
import Kit

@_silgen_name("proc_pid_rusage")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please avoid using @_silgen_name

@exelban
Copy link
Copy Markdown
Owner

exelban commented Apr 26, 2026

too many changes in one PR. You not only trying to improve RAM usage calculation, but also rewrite the whole top process logic. Too much in one PR.

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