TL;DR

A slow memory leak took down one of my production services at 2am. I spent the first hour guessing and the next hour actually fixing it — once I stopped guessing and started using Claude Code to work through heap snapshots systematically. Here's what actually happened, and the 4 lessons I took away about using an AI coding agent for real production debugging instead of toy examples.

The Problem

It started with a Slack alert: memory usage on one of my Node.js services climbing steadily, no plateau, no GC recovery. Classic slow leak. The kind that's fine for six hours and then, right around 2am, tips over into OOM kills and a crash loop.

I'd fixed leaks before, but always the easy kind — an obvious unbounded cache, a forgotten setInterval. This one wasn't obvious. The service had grown over two years, had a dozen contributors, and the leak only showed up under real traffic patterns I couldn't easily reproduce locally.