Interview practice question
Observers and listeners cause a memory leak
Frontend Engineering · Async JavaScript and the Browser · Intermediate
A component that uses ResizeObserver and window listeners leaks memory each time it's shown and hidden. How do you fix it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Disconnect observers on cleanup.
- Remove listeners with same reference or AbortSignal.
- Clear timers.
- Framework cleanup hooks.
- Verify with heap snapshots.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.