Skip to content

Commit 123af87

Browse files
mhdawsonRafaelGSS
authored andcommitted
doc: clarify behaviour of node-api adjust function
Refs: #57351 - based on recent request to update one of the tests Signed-off-by: Michael Dawson <[email protected]> PR-URL: #57463 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Vladimir Morozov <[email protected]>
1 parent 5115d95 commit 123af87

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

doc/api/n-api.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -6120,16 +6120,25 @@ NAPI_EXTERN napi_status napi_adjust_external_memory(node_api_basic_env env,
61206120
* `[in] env`: The environment that the API is invoked under.
61216121
* `[in] change_in_bytes`: The change in externally allocated memory that is kept
61226122
alive by JavaScript objects.
6123-
* `[out] result`: The adjusted value
6123+
* `[out] result`: The adjusted value. This value should reflect the
6124+
total amount of external memory with the given `change_in_bytes` included.
6125+
The absolute value of the returned value should not be depended on.
6126+
For example, implementations may use a single counter for all addons, or a
6127+
counter for each addon.
61246128

61256129
Returns `napi_ok` if the API succeeded.
61266130

6127-
This function gives V8 an indication of the amount of externally allocated
6128-
memory that is kept alive by JavaScript objects (i.e. a JavaScript object
6129-
that points to its own memory allocated by a native addon). Registering
6130-
externally allocated memory will trigger global garbage collections more
6131+
This function gives the runtime an indication of the amount of externally
6132+
allocated memory that is kept alive by JavaScript objects
6133+
(i.e. a JavaScript object that points to its own memory allocated by a
6134+
native addon). Registering externally allocated memory may, but is not
6135+
guaranteed to, trigger global garbage collections more
61316136
often than it would otherwise.
61326137

6138+
This function is expected to be called in a manner such that an
6139+
addon does not decrease the external memory more than it has
6140+
increased the external memory.
6141+
61336142
## Promises
61346143

61356144
Node-API provides facilities for creating `Promise` objects as described in

0 commit comments

Comments
 (0)