From 78be0d0f1ccba3c7a29f7d46319d17939a0be13d Mon Sep 17 00:00:00 2001 From: theanarkh Date: Wed, 13 Mar 2024 12:06:49 +0800 Subject: [PATCH] src: add uv_get_available_memory to report and process PR-URL: https://github.com/nodejs/node/pull/52023 Reviewed-By: Luigi Pinca Reviewed-By: Yagiz Nizipli Reviewed-By: Chengzhong Wu --- doc/api/process.md | 17 +++++++++++++++ lib/internal/bootstrap/node.js | 1 + src/env.cc | 21 +------------------ src/node_process_methods.cc | 7 +++++++ src/node_report.cc | 9 ++------ .../parallel/test-process-available-memory.js | 5 +++++ 6 files changed, 33 insertions(+), 27 deletions(-) create mode 100644 test/parallel/test-process-available-memory.js diff --git a/doc/api/process.md b/doc/api/process.md index e16659cd74498a..b0cbebcc148de8 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1127,6 +1127,22 @@ is unknown, `undefined` is returned. See [`uv_get_constrained_memory`][uv_get_constrained_memory] for more information. +## `process.availableMemory()` + + + +> Stability: 1 - Experimental + +* {number} + +Gets the amount of free memory that is still available to the process +(in bytes). + +See [`uv_get_available_memory`][uv_get_available_memory] for more +information. + ## `process.cpuUsage([previousValue])`