From f09b838408f6c775755daf05572b4b9712342148 Mon Sep 17 00:00:00 2001 From: theanarkh Date: Wed, 25 Jan 2023 08:47:08 +0800 Subject: [PATCH] src,lib: add constrainedMemory API for process PR-URL: https://github.com/nodejs/node/pull/46218 Reviewed-By: Yagiz Nizipli Reviewed-By: Darshan Sen --- doc/api/process.md | 18 ++++++++++++++++++ lib/internal/bootstrap/node.js | 1 + src/node_process_methods.cc | 9 +++++++++ .../test-process-constrained-memory.js | 12 ++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 test/parallel/test-process-constrained-memory.js diff --git a/doc/api/process.md b/doc/api/process.md index 6f81cf33d6a9ae..5b6ae09eda95b1 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1107,6 +1107,23 @@ 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()` + + + +> Stability: 1 - Experimental + +* {number|undefined} + +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, `undefined` is returned. + +See [`uv_get_constrained_memory`][uv_get_constrained_memory] for more +information. + ## `process.cpuUsage([previousValue])`