Skip to content

Commit b2c1aeb

Browse files
Trottdanielleadams
authored andcommittedJan 12, 2021
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: #36757 Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Yash Ladha <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]>
1 parent 9b7d2c2 commit b2c1aeb

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed
 

‎doc/api/process.md

+14-20
Original file line numberDiff line numberDiff line change
@@ -1575,26 +1575,19 @@ changes:
15751575
* `external` {integer}
15761576
* `arrayBuffers` {integer}
15771577

1578-
The `process.memoryUsage()` method returns an object describing the memory usage
1579-
of the Node.js process measured in bytes.
1580-
1581-
For example, the code:
1578+
Returns an object describing the memory usage of the Node.js process measured in
1579+
bytes.
15821580

15831581
```js
15841582
console.log(process.memoryUsage());
1585-
```
1586-
1587-
Will generate:
1588-
1589-
<!-- eslint-skip -->
1590-
```js
1591-
{
1592-
rss: 4935680,
1593-
heapTotal: 1826816,
1594-
heapUsed: 650472,
1595-
external: 49879,
1596-
arrayBuffers: 9386
1597-
}
1583+
// Prints:
1584+
// {
1585+
// rss: 4935680,
1586+
// heapTotal: 1826816,
1587+
// heapUsed: 650472,
1588+
// external: 49879,
1589+
// arrayBuffers: 9386
1590+
// }
15981591
```
15991592

16001593
* `heapTotal` and `heapUsed` refer to V8's memory usage.
@@ -1612,8 +1605,8 @@ Will generate:
16121605
When using [`Worker`][] threads, `rss` will be a value that is valid for the
16131606
entire process, while the other fields will only refer to the current thread.
16141607

1615-
The `process.memoryUsage()` method iterate over each page to gather
1616-
informations about memory usage which can be slow depending on the
1608+
The `process.memoryUsage()` method iterates over each page to gather
1609+
information about memory usage which might be slow depending on the
16171610
program memory allocations.
16181611

16191612
## `process.memoryUsage.rss()`
@@ -1630,7 +1623,8 @@ The Resident Set Size, is the amount of space occupied in the main
16301623
memory device (that is a subset of the total allocated memory) for the
16311624
process, including all C++ and JavaScript objects and code.
16321625

1633-
This is the same value as the one returned by `process.memoryUsage()`.
1626+
This is the same value as the `rss` property provided by `process.memoryUsage()`
1627+
but `process.memoryUsage.rss()` is faster.
16341628

16351629
```js
16361630
console.log(process.memoryUsage.rss());

0 commit comments

Comments
 (0)
Please sign in to comment.