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] env: The environment that the API is invoked under.

  • [in] change_in_bytes:由 JavaScript 对象保持活动状态的外部分配内存的变化。

    ¥[in] change_in_bytes: The change in externally allocated memory that is kept alive by JavaScript objects.

  • [out] result:调整值

    ¥[out] result: The adjusted value

如果 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.