-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
process: report ArrayBuffer memory in memoryUsage()
#31550
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
Changes from 1 commit
20947c7
5e624ba
ba44913
a6e74b3
4267523
a3014ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
memoryUsage()
Report memory allocations performed by the `ArrayBuffer::Allocator`.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1510,6 +1510,9 @@ is no entry script. | |
| <!-- YAML | ||
| added: v0.1.16 | ||
| changes: | ||
| - version: REPLACEME | ||
| pr-url: https://github.com/nodejs/node/pull/??? | ||
| description: Added `arrayBuffers` to the returned object. | ||
| - version: v7.2.0 | ||
| pr-url: https://github.com/nodejs/node/pull/9587 | ||
| description: Added `external` to the returned object. | ||
|
|
@@ -1520,6 +1523,7 @@ changes: | |
| * `heapTotal` {integer} | ||
| * `heapUsed` {integer} | ||
| * `external` {integer} | ||
| * `arrayBuffers` {integer} | ||
|
|
||
| The `process.memoryUsage()` method returns an object describing the memory usage | ||
| of the Node.js process measured in bytes. | ||
|
|
@@ -1538,19 +1542,21 @@ Will generate: | |
| rss: 4935680, | ||
| heapTotal: 1826816, | ||
| heapUsed: 650472, | ||
| external: 49879 | ||
| external: 49879, | ||
| arrayBuffers: 9386 | ||
| } | ||
| ``` | ||
|
|
||
| `heapTotal` and `heapUsed` refer to V8's memory usage. | ||
| `external` refers to the memory usage of C++ objects bound to JavaScript | ||
| objects managed by V8. `rss`, Resident Set Size, is the amount of space | ||
| occupied in the main memory device (that is a subset of the total allocated | ||
| memory) for the process, which includes the _heap_, _code segment_ and _stack_. | ||
|
|
||
| The _heap_ is where objects, strings, and closures are stored. Variables are | ||
| stored in the _stack_ and the actual JavaScript code resides in the | ||
| _code segment_. | ||
| * `heapTotal` and `heapUsed` refer to V8's memory usage. | ||
| * `external` refers to the memory usage of C++ objects bound to JavaScript | ||
| objects managed by V8. | ||
| * `rss`, Resident Set Size, is the amount of space occupied in the main | ||
| memory device (that is a subset of the total allocated memory) for the | ||
| process, including all C++ and JavaScript objects and code. | ||
| * `arrayBuffers` refers to memory allocated for `ArrayBuffer`s and | ||
| `SharedArrayBuffer`s, including all Node.js [`Buffer`][]s. | ||
| This is also included in the `external` value. When Node.js is used as an | ||
| embedded library, this value may be `0`. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry for being
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because embedders can specify their own
Inside the C++
I don’t really understand this question, sorry – there is nothing probabilistic involved here, I think?
I think that’s also answered by the first question, but let me know if I’m misunderstanding.
I think it’s safe to say that the value is trustworthy when it’s not I didn’t want to go into a ton of detail in the documentation here – imo there should be an indication that the value may not always be provided, and that tools should not make the expectation that the value is non-zero. But for a tool it’s not really going to matter why exactly the value can’t be reported, I think, other than that it’s related to the fact that the Node.js code is running in a specific environment that behaves differently.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I termed it as probabilistic because of if embedders use only non-node.js allocators without a tracker, then this value Are we on the same page?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gireeshpunathil Yes, we are 👍 I feel like the most important thing is that the doc makes clear that this does not affect standard Node.js binaries.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe a simple "because such allocations may not be tracked" would be good?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jasnell Sure, done 👍 |
||
|
|
||
| When using [`Worker`][] threads, `rss` will be a value that is valid for the | ||
| entire process, while the other fields will only refer to the current thread. | ||
|
|
@@ -2518,6 +2524,7 @@ cases: | |
| [`'exit'`]: #process_event_exit | ||
| [`'message'`]: child_process.html#child_process_event_message | ||
| [`'uncaughtException'`]: #process_event_uncaughtexception | ||
| [`Buffer`]: buffer.html | ||
| [`ChildProcess.disconnect()`]: child_process.html#child_process_subprocess_disconnect | ||
| [`ChildProcess.send()`]: child_process.html#child_process_subprocess_send_message_sendhandle_options_callback | ||
| [`ChildProcess`]: child_process.html#child_process_class_childprocess | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.