0
0
Node.jsframework~5 mins

Heap snapshot for memory leaks in Node.js - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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
Which Chrome DevTools tab do you use to take a heap snapshot?
AConsole
BMemory
CSources
DNetwork
What does a heap snapshot NOT show?
ARetainers of objects
BReferences between objects
CObjects in memory
DCPU 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
What is a common cause of memory leaks visible in heap snapshots?
AForgotten event listeners
BUnused variables
CFast CPU speed
DSmall heap size
Explain how to take and use a heap snapshot to find memory leaks in a Node.js app.
Think about the steps from starting the app to analyzing objects in memory.
You got /7 concepts.
    Describe what information a heap snapshot provides and why it is helpful for debugging memory issues.
    Focus on what you see in the snapshot and how it helps find leaks.
    You got /5 concepts.