napi_adjust_external_memory


NAPI_EXTERN napi_status napi_adjust_external_memory(node_api_nogc_env env,
                                                    int64_t change_in_bytes,
                                                    int64_t* result); 
  • [in] env:调用该 API 时所处的环境。
  • [in] change_in_bytes:由 JavaScript 对象保持活动状态的外部分配内存的变化量。
  • [out] result:调整后的值

如果 API 成功,则返回 napi_ok

【Returns napi_ok if the API succeeded.】

此函数向 V8 指示由 JavaScript 对象保持活动的外部分配内存的数量(即指向本地插件分配的自身内存的 JavaScript 对象)。注册外部分配的内存会比平时更频繁地触发全局垃圾回收。

【This function gives V8 an indication of the amount of externally allocated memory that is kept alive by JavaScript objects (i.e. a JavaScript object that points to its own memory allocated by a native addon). Registering externally allocated memory will trigger global garbage collections more often than it would otherwise.】