Which fix removes the bug?
const cache = new Map();
function remember(node, value) {
cache.set(node, value);
}
- Use a WeakMap or evict
- Clear it on each call
- Store values as JSON
- Key the map by index
A strong Map key keeps detached nodes alive forever, so the cache is a memory leak.
Play Problem Solving ▸