Starts monitoring the lifetime of target. Calls callback as soon as value has been garbage-collected, or the script is about to get unloaded.
target
callback
Useful when you're building a language-binding where you need to free native resources when a JS value is no longer needed.
Be careful so callback is not a closure that accidentally captures target and keeps it alive beyond its intended lifetime.
Heap-allocated JavaScript value to monitor lifetime of.
Function to call when target gets GCed.
Generated using TypeDoc
Starts monitoring the lifetime of
target
. Callscallback
as soon as value has been garbage-collected, or the script is about to get unloaded.Useful when you're building a language-binding where you need to free native resources when a JS value is no longer needed.
Be careful so
callback
is not a closure that accidentally capturestarget
and keeps it alive beyond its intended lifetime.