Created
October 23, 2017 20:17
-
-
Save krisselden/d41056416e0bc2c20cc476ea75ed6a57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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