weak collections, ephemerons, and private fields by Sigurd Schneider | JSCAMP 2019
summary
Explains how weak maps polyfill private fields by storing per-object side tables, contrasts that with in-object private slots, and shows why generational GC matters: the generational GC remembered set must track cross-generation pointers. Describes a pathological case where huge weak maps in old space keep many young keys alive, implements an old weak maps with yonke said that scans those maps during young collections, and reports a microbenchmark improvement from ~2 minutes to ~2 seconds at about 8 million objects.
AI-written summary · about
chapters (10)
- 0:00Start
- 4:43Distinguishing live and dead objects
- 9:18Ephemeron Semantics of WeakMap entries
- 17:15Observer without WeakRef
- 18:44The WeakRef Interface
- 20:33What does the generational hypothesis mean?
- 21:33Leveraging the generational hypothesis
- 22:52What about cross-generation references?
- 23:50V8 treats cross-generation links strongly
- 25:04Performance comparison
related talks
21mMemory: Don't Forget to Take Out the Garbage
42mES6 Collections in V8: There's Neon Inside
16mUsefulness and Uses of Weak Reference and Finalization Registry in Real Life
22mMastering JavaScript Collections: Arrays, Maps, Sets, and Beyond
24mTrash Talk - Understanding Memory Management
17mAlice's Adventures in Memory Management, or how JavaScript objects work
31mJavaScript memory management: Visual Guide
17mCollecting Cyclic Garbage across Foreign Function Interfaces: Who Takes the Last Piece(…)
