Monitor Memory Usage: Use process.memoryUsage() to track heap memory.
Chrome DevTools: Run with node --inspect and analyze the "Heap Snapshot" in Chrome.
Use clinic: Install and run:
npm install -g clinic
clinic doctor -- node app.js
- Heap Dumps: Use heapdump to capture snapshots for analysis.
- Event-based Detection: Use memwatch-next to detect leaks:
memwatch.on('leak', (info) => console.error('Leak:', info));