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

A long-lived module-level array `cache` keeps growing because a closure pushes a large DOM-detached subtree's wrapper object into it on each event. Even after the DOM nodes are removed from the document, memory keeps climbing. From the GC's perspective, why are those nodes not collected?

const cache = []; function onEvent(node) { cache.push({ node, ts: Date.now() }); }