Skip to content

Commit ad1981a

Browse files
Trotttargos
authored andcommitted
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 133620c commit ad1981a

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

doc/api/process.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,26 +1573,19 @@ changes:
15731573
* `external` {integer}
15741574
* `arrayBuffers` {integer}
15751575

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

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

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

1613-
The `process.memoryUsage()` method iterate over each page to gather
1614-
informations about memory usage which can be slow depending on the
1606+
The `process.memoryUsage()` method iterates over each page to gather
1607+
information about memory usage which might be slow depending on the
16151608
program memory allocations.
16161609

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

1631-
This is the same value as the one returned by `process.memoryUsage()`.
1624+
This is the same value as the `rss` property provided by `process.memoryUsage()`
1625+
but `process.memoryUsage.rss()` is faster.
16321626

16331627
```js
16341628
console.log(process.memoryUsage.rss());

0 commit comments

Comments
 (0)