Node.js · Senior · Question 4 of 75
How do you find what is leaking in a Node.js process?
- ✓Correct answer: Take several heap snapshots over time (
v8.writeHeapSnapshot()or DevTools) and compare which object counts keep growing - 2Increase
--max-old-space-sizeuntil the crashes stop - 3Restart the process every hour
Explanation
The comparison view shows objects allocated between snapshots, and retainer paths show what keeps them alive. --heapsnapshot-near-heap-limit can take a snapshot right before a crash.