Skip to content

fix(memory): switch to privateBytes and add EMA trend detection#3360

Merged
gregpriday merged 2 commits intodevelopfrom
feature/issue-3285-processmemorymonitor-uses
Mar 16, 2026
Merged

fix(memory): switch to privateBytes and add EMA trend detection#3360
gregpriday merged 2 commits intodevelopfrom
feature/issue-3285-processmemorymonitor-uses

Conversation

@gregpriday
Copy link
Collaborator

Summary

  • Replaces workingSetSize with privateBytes for all threshold comparisons and trend analysis, eliminating false positives caused by OS memory compression on macOS
  • Adds EMA-based trend detection over a rolling 30-minute window using bucket minimums to filter GC sawtooth noise, detecting slow leaks (default threshold: 5 MB/hour)
  • Suppresses trend evaluation for the first 15 minutes after monitor start to absorb V8 JIT and startup allocation bursts

Resolves #3285

Changes

  • electron/services/ProcessMemoryMonitor.ts: EMA trend tracking, bucket-minimum rolling history, startup suppression window, privateBytes-based absolute thresholds
  • electron/services/__tests__/ProcessMemoryMonitor.test.ts: new tests covering trend detection, startup window suppression, GC spike immunity, and existing snapshot behavior

Testing

Full unit test suite passes. The two implementation commits cover the core metric switch and a follow-up fix for bucket overlap and growth rate denominator accuracy.

- Replace workingSetSize with privateBytes (fallback to workingSetSize on non-Windows)
- Add per-PID bucket-minimum filtering (60s buckets) to smooth GC sawtooth
- Add EMA-based trend detection with 5 MB/hr threshold warning
- Suppress trend evaluation for first 15 minutes and until 30 buckets accumulated
- Prune stale PID state when processes exit
- Add tests for privateBytes preference, fallback, trend detection, startup suppression, and spike absorption
- Reset bucketMin to Infinity after commit to prevent next bucket from including last sample of previous bucket
- Use (BUCKET_WINDOW - 1) intervals for growth rate denominator (29 intervals, not 30)
- Clarify test names and comments to accurately describe suppression behavior
@gregpriday
Copy link
Collaborator Author

Review status: Ready

@gregpriday gregpriday merged commit 64d0b29 into develop Mar 16, 2026
4 checks passed
@gregpriday gregpriday deleted the feature/issue-3285-processmemorymonitor-uses branch March 16, 2026 06:25
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.

ProcessMemoryMonitor uses workingSetSize instead of privateBytes and lacks trend detection

1 participant