JavaScript · Senior · Question 10 of 75

Which scenario typically causes a memory leak in an SPA?

Explanation

A subscription holds a closure, and through it the component's data and DOM nodes. Other sources: detached DOM nodes referenced from JS, growing global caches, forgotten setIntervals. Short-lived objects are efficiently collected by the GC's young generation. Leaks are found with Memory snapshots in DevTools.

Further reading

Problem with a question

JavaScript · Senior · question 10

Test yourself

Take the JavaScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz