From 73c0564fcaea8dba8b480fefec4e9f1099a9cb91 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 80fa2f826de93a..4a4a60c2735d98 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1103,6 +1103,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])`