Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a heap snapshot in Node.js?
A heap snapshot is a detailed record of the memory used by a Node.js application at a specific time. It shows all objects in memory and their relationships, helping to find memory leaks.
Click to reveal answer
beginner
How do you take a heap snapshot using Chrome DevTools with Node.js?
You start your Node.js app with the --inspect flag, open Chrome DevTools, connect to the Node process, go to the Memory tab, and click 'Take heap snapshot'.
Click to reveal answer
intermediate
Why are heap snapshots useful for finding memory leaks?
Heap snapshots show which objects stay in memory longer than expected. By comparing snapshots over time, you can spot objects that should be gone but are still kept, indicating leaks.
Click to reveal answer
intermediate
What does the 'Retainers' view in a heap snapshot show?
The 'Retainers' view shows what other objects are keeping a selected object in memory. This helps find why an object is not being removed and causing a memory leak.
Click to reveal answer
beginner
Name one common cause of memory leaks visible in heap snapshots.
One common cause is forgotten event listeners or timers that keep references to objects, preventing garbage collection.
Click to reveal answer
What flag do you use to enable debugging for heap snapshots in Node.js?
A--memory-check
B--debug
C--inspect
D--heap-snapshot
✗ Incorrect
The --inspect flag enables the Node.js process to be debugged and connected to Chrome DevTools for heap snapshots.
Which Chrome DevTools tab do you use to take a heap snapshot?
AConsole
BMemory
CSources
DNetwork
✗ Incorrect
The Memory tab in Chrome DevTools is used to take heap snapshots and analyze memory usage.
What does a heap snapshot NOT show?
ARetainers of objects
BReferences between objects
CObjects in memory
DCPU usage
✗ Incorrect
Heap snapshots focus on memory, not CPU usage.
If an object is still in memory but should be gone, what might this indicate?
AA memory leak
BGarbage collection is working fine
CThe app is idle
DThe object is a primitive type
✗ Incorrect
Objects that stay in memory unexpectedly often indicate a memory leak.
What is a common cause of memory leaks visible in heap snapshots?