This article needs a technical review. How you can help.
JSFinalizeOp is the type of
typedef void (* JSFinalizeOp)(JSFreeOp *fop, JSObject *obj);
||The JS context in which garbage collection is taking place.|
||The object being destroyed.|
JSFinalizeOp is analogous to Java finalizers or C++ destructors. The garbage collector calls this callback for each object it collects. The finalizer's job is to clean up any resources allocated by the instance which wouldn't normally be cleaned up by the garbage collector (private data stored in the object by the application, file handles, etc.)
Finalizers must never store a reference to
Warning: This hook is called during garbage collection. Any JSAPI call that would allocate memory from the GC heap will fail if called from a finalizer.
For other ways to interact with garbage collection (e.g. implementing weak references), see
JSClass offers the following hook: