← All talks
2014 tim.js Meetup Timisoara, Romania

JavaScript Debugging with Chrome DevTools (Part 3)

The final chapter: auditing, CPU profiling, and memory leak detection. The advanced DevTools skills that separate debugging novices from debugging experts.

JavaScriptDebuggingChrome DevToolsMemory Profiling

Why this talk matters

Part 3 was the culmination of the DevTools series, tackling the most advanced and least understood tools: the Audits panel, CPU profiling, and heap snapshots for memory leak detection.

Memory leaks in JavaScript are notoriously hard to track down. Detached DOM nodes, forgotten event listeners, closures holding references to large objects. This session walked through real examples of each, using the heap snapshot comparison technique to isolate the leaking objects.

At 140 views, this was the most-viewed part of the series. That makes sense: memory profiling content is rare because it is hard to teach well. Developers seek it out when they have a real problem to solve.

Key takeaways

  • Memory leaks in JavaScript almost always come from three sources: detached DOM nodes, forgotten event listeners, and closures that outlive their intended scope.
  • Heap snapshot comparison is the most reliable technique for finding leaks. Take a snapshot, perform the action, take another snapshot, and compare.
  • CPU profiling reveals which functions consume the most time. The flame chart makes hotspots visually obvious in a way that timing logs never can.
  • The Audits panel (now Lighthouse) gives you an instant checklist of performance, accessibility, and best practice improvements. Run it before every release.

Presented at the 5th JavaScript Meetup in Timisoara on January 29th, 2014. This final session attracted the biggest crowd of the series because word had spread that the content was genuinely useful and hard to find elsewhere.