Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/charmander/gc-listen

Calls a function when V8 collects an object as garbage
https://github.com/charmander/gc-listen

garbage-collection nodejs v8

Last synced: about 1 month ago
JSON representation

Calls a function when V8 collects an object as garbage

Awesome Lists containing this project

README

        

## gc-listen

A way to attach a JavaScript function with `napi_add_finalizer`. For debugging.

```javascript
const gcListen = require('gc-listen');

const obj = {};

const callback = () => {
// …
};

gcListen(obj, callback);
```

`callback` won’t be called as long as `obj` isn’t eligible for garbage collection. N-API even suggests it will be called *when* `obj` is collected. It will always be called asynchronously when called at all.