Memory Leaks in JavaScript
summary
Shows how to find and fix concrete leaks using MemLab and Chrome DevTools with live demos: creating 10,000 divs and taking heap snapshots that show a +1.2 MB delta, inspecting detached DOM nodes, implicit globals, closures that keep whole arrays, and forgotten intervals or event listeners. Walks through taking snapshots, using comparison and statistics, nulling references, removing listeners or clearing timers, and extracting single values instead of retaining big arrays; notes MemLab automates leak detection but can take substantial time to run.
AI-written summary · about
chapters (18)
- 0:00Memory leaks in JavaScript
- 1:03Memory management basics
- 3:38Memory leak definition and impact
- 5:01Stack vs heap memory
- 7:12Stack overflow and heap issues
- 8:16Garbage collection mark and sweep
- 11:32Demo: memory leak in Chrome DevTools
- 14:03Heap snapshots for leaks
- 17:27Global variables as leaks
- 19:58Fixing global leaks with let/const
- 21:47Detached DOM nodes cause leaks
- 23:12Closures and memory leaks
- 25:24Closures and timeouts
- 25:44Event listeners and intervals
- 26:30MemLab for leak detection
- 27:56Heap analysis with timeline profiler
- 29:01Maps and sets prevent leaks
- 30:05Summary: leaks and tools
related talks
24mDemystifying Memory Leaks in JavaScript
19mUnderstand, find, prevent and fix memory leaks in JavaScript
20mMemory Leaks and the Havoc They Wreak
35mMemory Chronicles: Manage, Trace and Fix Memory Leaks
23mWarp Speed Memory Management
53mPlugging Memory Leaks With The Chrome Dev Tools
38mUnderstanding Memory Behavior on Nodejs
30mMemory Don't Forget To Take Out The Garbage
