From 859f8efa99ede7811bf2a30d62ac7f421b7c4ced 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 | 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 | 10 +++++++++ 6 files changed, 38 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 48901d5c40cfde..d4de186f5ffad1 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])`