fix(memory): switch to privateBytes and add EMA trend detection#3360
Merged
gregpriday merged 2 commits intodevelopfrom Mar 16, 2026
Merged
fix(memory): switch to privateBytes and add EMA trend detection#3360gregpriday merged 2 commits intodevelopfrom
gregpriday merged 2 commits intodevelopfrom
Conversation
- 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
Collaborator
Author
|
Review status: Ready
|
This was referenced Mar 16, 2026
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.
Summary
workingSetSizewithprivateBytesfor all threshold comparisons and trend analysis, eliminating false positives caused by OS memory compression on macOSResolves #3285
Changes
electron/services/ProcessMemoryMonitor.ts: EMA trend tracking, bucket-minimum rolling history, startup suppression window,privateBytes-based absolute thresholdselectron/services/__tests__/ProcessMemoryMonitor.test.ts: new tests covering trend detection, startup window suppression, GC spike immunity, and existing snapshot behaviorTesting
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.