FinalizationRegistry
A JavaScript object that lets you register a callback to run some time after a given object has been garbage collected.
In more detail
You register an object with some held value, and the callback later receives that value. It is handy for diagnostics and releasing external resources, but callbacks may run late or never, so do not depend on them for correctness.
Related terms
- WeakRef — An object that holds a weak reference to another object; deref() returns the object, or undefined once it has been collected.
- garbage collection — The automatic freeing of memory held by objects that the program can no longer reach.
Taught in
- Memory Management: Garbage Collection, Memory Leaks And WeakMap — Frontend Architecture & Web Platform