doc: add comment about highWaterMark limit

Add a comment regarding memory limits and setting highWaterMark

PR-URL: https://github.com/nodejs/node/pull/33432
Reviewd-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>

Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Benjamin Gruenbaum 2020-05-16 14:53:36 +03:00 committed by Anna Henningsen
parent 3abb52fdb6
commit b51d1cfbf2
No known key found for this signature in database
GPG Key ID: A94130F0BFC8EBE9

View File

@ -93,6 +93,11 @@ A key goal of the `stream` API, particularly the [`stream.pipe()`][] method,
is to limit the buffering of data to acceptable levels such that sources and is to limit the buffering of data to acceptable levels such that sources and
destinations of differing speeds will not overwhelm the available memory. destinations of differing speeds will not overwhelm the available memory.
The `highWaterMark` option is a threshold, not a limit: it dictates the amount
of data that a stream buffers before it stops asking for more data. It does not
enforce a strict memory limitation in general. Specific stream implementations
may choose to enforce stricter limits but doing so is optional.
Because [`Duplex`][] and [`Transform`][] streams are both `Readable` and Because [`Duplex`][] and [`Transform`][] streams are both `Readable` and
`Writable`, each maintains *two* separate internal buffers used for reading and `Writable`, each maintains *two* separate internal buffers used for reading and
writing, allowing each side to operate independently of the other while writing, allowing each side to operate independently of the other while