Skip to content

Commit bc5cdd6

Browse files
committed
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.
1 parent 83ab543 commit bc5cdd6

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
@@ -1552,26 +1552,19 @@ changes:
15521552
* `external` {integer}
15531553
* `arrayBuffers` {integer}
15541554

1555-
The `process.memoryUsage()` method returns an object describing the memory usage
1556-
of the Node.js process measured in bytes.
1557-
1558-
For example, the code:
1555+
Returns an object describing the memory usage of the Node.js process measured in
1556+
bytes.
15591557

15601558
```js
15611559
console.log(process.memoryUsage());
1562-
```
1563-
1564-
Will generate:
1565-
1566-
<!-- eslint-skip -->
1567-
```js
1568-
{
1569-
rss: 4935680,
1570-
heapTotal: 1826816,
1571-
heapUsed: 650472,
1572-
external: 49879,
1573-
arrayBuffers: 9386
1574-
}
1560+
// Prints:
1561+
// {
1562+
// rss: 4935680,
1563+
// heapTotal: 1826816,
1564+
// heapUsed: 650472,
1565+
// external: 49879,
1566+
// arrayBuffers: 9386
1567+
// }
15751568
```
15761569

15771570
* `heapTotal` and `heapUsed` refer to V8's memory usage.
@@ -1589,8 +1582,8 @@ Will generate:
15891582
When using [`Worker`][] threads, `rss` will be a value that is valid for the
15901583
entire process, while the other fields will only refer to the current thread.
15911584

1592-
The `process.memoryUsage()` method iterate over each page to gather
1593-
informations about memory usage which can be slow depending on the
1585+
The `process.memoryUsage()` method iterates over each page to gather
1586+
information about memory usage which might be slow depending on the
15941587
program memory allocations.
15951588

15961589
## `process.memoryUsage.rss()`
@@ -1604,7 +1597,8 @@ The Resident Set Size, is the amount of space occupied in the main
16041597
memory device (that is a subset of the total allocated memory) for the
16051598
process, including all C++ and JavaScript objects and code.
16061599

1607-
This is the same value as the one returned by `process.memoryUsage()`.
1600+
This is the same value as the `rss` property provided by `process.memoryUsage()`
1601+
but `process.memoryUsage.rss()` is faster.
16081602

16091603
```js
16101604
console.log(process.memoryUsage.rss());

0 commit comments

Comments
 (0)