Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavaScriptgarbage collection and leaksSingle-choice MCQ

You replace a `Map` that maps long-lived key objects to large cached values with a `WeakMap` to 'fix a leak'. The keys are still referenced strongly elsewhere for the lifetime of the app. What is the real effect on retention?

const big = makeHugeValue(); const wm = new WeakMap(); wm.set(keyObj, big); // keyObj is also held by a long-lived registry