GC Signals
A primitive way to know when an object got garbage collected. It works by creating an object holding onto a numeric identifier. On de-construction that identifer is put into a list which can be consumed to learn whether an object was been gc'ed or not.
const {GCSignal, consumeSignals} = require('gc-signals');
new GCSignal(1);
new GCSignal(2);
new GCSignal(3);
// gc happens...
consumeSignals() // [1,2,3];
API
export interface GCSignal {
}
export declare const GCSignal: {
new (id: number): GCSignal;
};
export declare function consumeSignals(): number[];
export declare function onDidGarbageCollectSignals(callback: (ids: number[]) => any): {
dispose(): void;
};
export declare function trackGarbageCollection(obj: any, id: number): number;