napi_adjust_external_memory
NAPI_EXTERN napi_status napi_adjust_external_memory(node_api_basic_env env,
int64_t change_in_bytes,
int64_t* result); [in] env:调用该 API 时所处的环境。[in] change_in_bytes:由 JavaScript 对象保持活动状态的外部分配内存的变化量。[out] result:调整后的值。该值应反映包含给定change_in_bytes后的外部内存总量。返回值的绝对值不应被依赖。例如,具体实现可能为所有插件使用单个计数器,或者为每个插件使用各自的计数器。
如果 API 成功,则返回 napi_ok。
【Returns napi_ok if the API succeeded.】
此函数向运行时指示由 JavaScript 对象保留的外部分配内存的数量(即指向其自己由本地插件分配的内存的 JavaScript 对象)。注册外部分配的内存可能会,但不保证,会比平时更频繁地触发全局垃圾回收。
【This function gives the runtime 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 may, but is not guaranteed to, trigger global garbage collections more often than it would otherwise.】
该函数的调用预期应确保,附加组件不会使外部内存的减少超过其增加的外部内存量。
【This function is expected to be called in a manner such that an addon does not decrease the external memory more than it has increased the external memory.】