FinalizationRegistry : Object
FinalizationRegistry provides a way to be notified when an object is garbage collected. Note, JavaScript makes no guarantees on if or when an object will be garbage collected. See also WeakRef.
Constructors
Returns a new FinalizationRegistry that will call cleanupCallback when objects passed to register() are garbage collected.
Example:
RunResults:
Instance Methods
Registers target with this so the cleanupCallback passed to this' constructor will be called when target is garbage collected.
The value passed to cleanupCallback at that time will be heldValue. Note target and heldValue can not be the same object because this will hold a strong reference to heldValue, preventing it from being garbage collected.
If unregisterToken is specified, you can prevent cleanupCallback from being called by calling unregister(unregisterToken).
Example:
RunResults:
Copyright © JavaScripture Contributors