MemLab is an end-to-end testing and analysis framework for identifying JavaScript memory leaks and optimization opportunities. Version 2.0.1 is the latest stable release, actively maintained by Meta. It provides automated browser memory leak detection using Puppeteer, a heap snapshot analysis API for Node.js/Electron/Hermes, and CLI tools for memory debugging. Key differentiators: supports custom leak detectors, object-oriented heap traversing, and integrates with unit testing. MemLab goes beyond simple heap dump analysis by automatically comparing snapshots and filtering leaks with retainer traces.
npm install memlabVerified import paths — ran on the pinned version, not inferred.
Demonstrates using MemLab's programmatic API to define a scenario and run browser memory leak detection.
Use import syntax instead of require().
Use '--runner puppeteer' instead of '--browser puppeteer'.
Define scenario as {url, action, back} instead.Monitor disk usage; consider using --max-snapshots option to limit files.
Set headless: false in Puppeteer launch options within scenario.
Ensure the website serves non-minified code or source maps for readable traces.
Replace const memlab = require('memlab') with import memlab from 'memlab'.Run npm install --save-dev puppeteer to install it.
Define an async 'back' function that returns to the pre-action state.
Override work directory with memlab.setWorkDir('/custom/path') or run with sudo.