Recall & Review
beginner
What is a memory leak in Node.js?
A memory leak happens when a program keeps using more and more memory because it doesn't release memory it no longer needs. This can slow down or crash the app.
Click to reveal answer
beginner
How can global variables cause memory leaks?
Global variables stay in memory for the whole app life. If you store large data there and never clear it, memory keeps growing.
Click to reveal answer
intermediate
Why do event listeners cause memory leaks?
If you add event listeners but never remove them, they keep references to objects, so memory can't be freed.
Click to reveal answer
intermediate
What is a closure-related memory leak?
Closures keep references to variables even after the outer function finishes. If those variables hold big data and are not cleared, memory leaks happen.
Click to reveal answer
beginner
How can caching cause memory leaks?
If you cache data without limits or expiration, the cache grows forever, using more memory.
Click to reveal answer
Which of these is a common cause of memory leaks in Node.js?
✗ Incorrect
Event listeners keep references to objects. If not removed, they cause memory leaks.
What happens if you keep large objects in global variables?
✗ Incorrect
Global variables stay in memory as long as the app runs, causing memory to grow if large objects are stored.
How can closures lead to memory leaks?
✗ Incorrect
Closures keep variables alive, so if those variables hold big data, memory is not freed.
What is a safe way to avoid cache-related memory leaks?
✗ Incorrect
Setting limits or expiration ensures cache does not grow forever.
Which tool can help find memory leaks in Node.js?
✗ Incorrect
Chrome DevTools heap profiler helps analyze memory usage and find leaks.
Explain three common patterns that cause memory leaks in Node.js and how to avoid them.
Think about what keeps data in memory longer than needed.
You got /4 concepts.
Describe how caching can lead to memory leaks and what strategies help prevent this.
Consider what happens if cache never clears old data.
You got /4 concepts.