// the find
facebook/memlab
A framework for finding JavaScript memory leaks and analyzing heap snapshots
memlab is Meta's framework for catching JavaScript memory leaks by driving Puppeteer through a scripted interaction, diffing heap snapshots before and after, and surfacing retainer traces for whatever didn't get garbage collected. It also ships a standalone heap-analysis API/CLI for working with .heapsnapshot files directly (V8, Hermes, Node, Electron) and, as of this release, an MCP server so an AI assistant can poke at a snapshot interactively. Best fit for frontend teams chasing a specific leak or wanting an automated leak-detection step in E2E tests.
The object-oriented heap traversal API is the real value here — you get a queryable graph of the snapshot instead of manually clicking through Chrome DevTools, which makes writing a custom leakFilter straightforward. It isn't browser-only: the same core handles V8, Hermes, and Electron snapshots, so it works for React Native and desktop Electron apps, not just web pages. The Node memory-assertion API (takeNodeMinimalHeap) is a nice unlock — you can assert in a unit test that an object was actually collected, which is otherwise nearly impossible to test deterministically. The new MCP server is a genuinely useful idea: exposing retainer-trace lookup, largest-object queries, and detached-DOM detection as tools means an assistant can drive the investigation conversationally instead of you eyeballing a dumped trace.
E2E leak detection needs a real scripted Puppeteer scenario (url/action/back), which is fine for Google Maps-style click flows but gets fiddly fast for SPAs with async routing, auth walls, or state that doesn't reset cleanly on 'back'. Retainer traces are only readable if the target site ships non-minified code with real identifiers — against a typical production bundle you'll be matching object IDs by hand in DevTools instead. The trace clustering/similarity logic (the ML-based HAC/TF-IDF bucketing) is internal machinery that's opaque if your leak doesn't match the built-in filter rules, and extending it means reading fairly dense code with little documentation. It's Meta-maintained at Meta's priorities — useful filters for their own dogfood cases exist, but if your leak pattern is unusual you're mostly on your own writing a custom leakFilter rather than finding existing coverage.