Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/charmander/gc-listen
- Owner: charmander
- License: isc
- Created: 2018-11-28T12:39:59.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-30T10:35:57.000Z (over 4 years ago)
- Last Synced: 2024-11-16T08:34:31.437Z (about 2 months ago)
- Topics: garbage-collection, nodejs, v8
- Language: C
- Homepage: https://www.npmjs.com/package/gc-listen
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.