mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
doc: revise process.memoryUsage() text
Some general edits, but also adding an explanation of why one might choose process.memoryUsage.rss() over process.memoryUsage().rss. PR-URL: https://github.com/nodejs/node/pull/36757 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Yash Ladha <yash@yashladha.in> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
This commit is contained in:
parent
e5b8c61717
commit
cfed0019ba
@ -1575,26 +1575,19 @@ changes:
|
|||||||
* `external` {integer}
|
* `external` {integer}
|
||||||
* `arrayBuffers` {integer}
|
* `arrayBuffers` {integer}
|
||||||
|
|
||||||
The `process.memoryUsage()` method returns an object describing the memory usage
|
Returns an object describing the memory usage of the Node.js process measured in
|
||||||
of the Node.js process measured in bytes.
|
bytes.
|
||||||
|
|
||||||
For example, the code:
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
console.log(process.memoryUsage());
|
console.log(process.memoryUsage());
|
||||||
```
|
// Prints:
|
||||||
|
// {
|
||||||
Will generate:
|
// rss: 4935680,
|
||||||
|
// heapTotal: 1826816,
|
||||||
<!-- eslint-skip -->
|
// heapUsed: 650472,
|
||||||
```js
|
// external: 49879,
|
||||||
{
|
// arrayBuffers: 9386
|
||||||
rss: 4935680,
|
// }
|
||||||
heapTotal: 1826816,
|
|
||||||
heapUsed: 650472,
|
|
||||||
external: 49879,
|
|
||||||
arrayBuffers: 9386
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
* `heapTotal` and `heapUsed` refer to V8's memory usage.
|
* `heapTotal` and `heapUsed` refer to V8's memory usage.
|
||||||
@ -1612,8 +1605,8 @@ Will generate:
|
|||||||
When using [`Worker`][] threads, `rss` will be a value that is valid for the
|
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.
|
entire process, while the other fields will only refer to the current thread.
|
||||||
|
|
||||||
The `process.memoryUsage()` method iterate over each page to gather
|
The `process.memoryUsage()` method iterates over each page to gather
|
||||||
informations about memory usage which can be slow depending on the
|
information about memory usage which might be slow depending on the
|
||||||
program memory allocations.
|
program memory allocations.
|
||||||
|
|
||||||
## `process.memoryUsage.rss()`
|
## `process.memoryUsage.rss()`
|
||||||
@ -1630,7 +1623,8 @@ The 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
|
memory device (that is a subset of the total allocated memory) for the
|
||||||
process, including all C++ and JavaScript objects and code.
|
process, including all C++ and JavaScript objects and code.
|
||||||
|
|
||||||
This is the same value as the one returned by `process.memoryUsage()`.
|
This is the same value as the `rss` property provided by `process.memoryUsage()`
|
||||||
|
but `process.memoryUsage.rss()` is faster.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
console.log(process.memoryUsage.rss());
|
console.log(process.memoryUsage.rss());
|
||||||
|
Loading…
Reference in New Issue
Block a user