-
Notifications
You must be signed in to change notification settings - Fork 16.3k
feat: add fileBacked
and purgeable
fields to process.getSystemMemoryInfo()
for macOS
#47628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add fileBacked
and purgeable
fields to process.getSystemMemoryInfo()
for macOS
#47628
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to expose new numbers, not change existing ones as people will have existing metrics that we'd be breaking.
Also cc @felixrieseberg because I know you've stared at how memory metrics work a lot in the past, any thoughts here
@MarshallOfSound I agree with you. I have changed the code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Could you please also adjust the docs?
Line 206 in 655037f
### `process.getSystemMemoryInfo()` |
Could you please also update the PR title and release notes to reflect your most recent change?
getSystemMemoryInfo()
@nikwen |
getSystemMemoryInfo()
getSystemMemoryInfo()
@@ -183,8 +183,11 @@ v8::Local<v8::Value> ElectronBindings::GetSystemMemoryInfo( | |||
#endif | |||
dict.Set("free", free); | |||
|
|||
#if BUILDFLAG(IS_MAC) | |||
dict.Set("cached", mem_info.file_backed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be named fileBacked
instead? I see another property named cached
and want to make sure this won't conflict in the future.
https://source.chromium.org/chromium/chromium/src/+/main:base/process/process_metrics.h;l=365;drc=17b4c42cfb3512836655464b0d41d319e819c0b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this field name might be better, I have considered using this name before.
Originally I wanted to make the name of this field consistent with what is displayed in the Activity Monitor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple suggestions for tweaking the docs wording
b28f1be
to
37ef641
Compare
@codebytere |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding docs! The code looks fine to me.
- Could you please update the release notes in the PR description?
- Could you please use a more descriptive title for the PR? This will be the commit message once the PR is merged.
getSystemMemoryInfo()
getSystemMemoryInfo()
for macOS.
getSystemMemoryInfo()
for macOS.
@nikwen |
Thanks for the changes! Please take a look at the commit message guidelines. The "add" in the PR title should be present tense and lowercase. Additionally, it's always great to wrap any function or field names in backticks to render them as code, e.g., |
fileBacked
and purgeable
fields to process.getSystemMemoryInfo()
for macOS
Thanks. |
Thanks! We use present tense and lowercase for commit messages ("add"). We use past tense and capitalized for release notes ("Added"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
Co-authored-by: Will Anderson <will@itsananderson.com>
37ef641
to
7e9faab
Compare
@codebytere |
Description of Change
On macOS, the free value in the memory data obtained from process.getSystemMemoryInfo() differs significantly from the value displayed in Activity Monitor.
The reason is that the free value is calculated from free_count in vm_statistics64_data_t.
The relevant code is located in: https://source.chromium.org/chromium/chromium/src/+/main:base/process/process_metrics_apple.mm;drc=bcbe20a25707502c2ba340cfd4dbe8cd015fa864;l=255
To handle this issue, I propose two approaches:
Calculate and return the adjusted value directly in electron_bindings.cc while maintaining the original data format.
Add two new fields: cached and purgeable, to provide more granular memory usage details.
Checklist
npm test
passesRelease Notes
Notes: Added
fileBacked
andpurgeable
fields toprocess.getSystemMemoryInfo()
for macOS.