From 8ee559bbc66a4f3c5e6077750702e9fbe13769c6 Mon Sep 17 00:00:00 2001 From: Rafael Gonzaga Date: Fri, 13 Jan 2023 03:33:29 +0000 Subject: [PATCH] lib: reuse invalid state errors on webstreams Signed-off-by: RafaelGSS PR-URL: https://github.com/nodejs/node/pull/46086 Reviewed-By: Robert Nagy Reviewed-By: Yagiz Nizipli Reviewed-By: Matteo Collina --- doc/api/process.md | 15 +++++++++++ lib/internal/bootstrap/node.js | 1 + lib/internal/process/per_thread.js | 8 ++++++ src/node_process.h | 6 +++++ src/node_process_methods.cc | 27 +++++++++++++++++++ .../test-process-constrained-memory.js | 13 +++++++++ 6 files changed, 70 insertions(+) create mode 100644 test/parallel/test-process-constrained-memory.js diff --git a/doc/api/process.md b/doc/api/process.md index 80fa2f826de93a..7e2144afbc7dfd 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1103,6 +1103,21 @@ and [Cluster][] documentation), the `process.connected` property will return Once `process.connected` is `false`, it is no longer possible to send messages over the IPC channel using `process.send()`. +## `process.constrainedMemory()` + + + +* {number} + +Gets the amount of memory available to the process (in bytes) based on +limits imposed by the OS. If there is no such constraint, or the constraint +is unknown, `0` is returned. It is not unusual for this value to +be less than or greater than `os.totalmem()`. This function currently only +returns a non-zero value on Linux, based on cgroups if it is present, and +on z/OS based on `RLIMIT_MEMLIMIT`. + ## `process.cpuUsage([previousValue])`