Skip to content

Instantly share code, notes, and snippets.

@krisselden
Created October 23, 2017 20:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save krisselden/d41056416e0bc2c20cc476ea75ed6a57 to your computer and use it in GitHub Desktop.
Save krisselden/d41056416e0bc2c20cc476ea75ed6a57 to your computer and use it in GitHub Desktop.
// d8 --expose-gc --allow-natives-syntax --track-retaining-path weak-value-retaining-path.js
class SomeKey {
}
class Metadata {
constructor() {
this.large = new LargeObject();
}
}
class LargeObject {
constructor () {
this.buffer = new Uint8Array(10 * 1024 * 1024);
}
}
let key = new SomeKey();
const map = new WeakMap();
(() => {
let meta = new Metadata();
%DebugTrackRetainingPath(meta);
map.set(key, meta);
})();
gc();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment