asyncId 对应的资源销毁后调用。 它也从嵌入器 API emitDestroy() 异步调用。

有些资源依赖垃圾回收来清理,所以如果引用传给 initresource 对象,可能永远不会调用 destroy,从而导致应用程序内存泄漏。 如果资源不依赖垃圾回收,则这不是问题。

使用销毁钩子会导致额外的开销,因为它可以通过垃圾收集器跟踪 Promise 实例。

Called after the resource corresponding to asyncId is destroyed. It is also called asynchronously from the embedder API emitDestroy().

Some resources depend on garbage collection for cleanup, so if a reference is made to the resource object passed to init it is possible that destroy will never be called, causing a memory leak in the application. If the resource does not depend on garbage collection, then this will not be an issue.

Using the destroy hook results in additional overhead because it enables tracking of Promise instances via the garbage collector.