From cc188ac13374466a1f69a11261b6a02164f173cb Mon Sep 17 00:00:00 2001 From: theanarkh Date: Sat, 9 Mar 2024 14:18:51 +0800 Subject: [PATCH] src: add uv_get_available_memory to report and process --- doc/api/process.md | 16 ++++++++++++++++ lib/internal/bootstrap/node.js | 1 + src/node_process_methods.cc | 7 +++++++ src/node_report.cc | 13 +++---------- test/common/report.js | 10 +++------- test/parallel/test-process-available-memory.js | 10 ++++++++++ 6 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 test/parallel/test-process-available-memory.js diff --git a/doc/api/process.md b/doc/api/process.md index 48901d5c40cfde..0cea77628b5481 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1127,6 +1127,21 @@ 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. + +See [`uv_get_available_memory`][uv_get_available_memory] for more +information. + ## `process.cpuUsage([previousValue])`