npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@memlab/cli

v2.0.7

Published

command line interface for memlab

Readme

@memlab/cli

The memlab command-line interface: every memlab command, its options, and the dispatcher that runs them. It provides the memlab binary.

Most people install the CLI through the memlab package, which bundles it with the rest of memlab:

npm install -g memlab

Installing @memlab/cli directly gives you the same memlab command.

Find memory leaks in a web page

Write a test scenario: the page to load, the interaction you suspect leaks memory, and how to undo it. page is a Puppeteer Page:

// test-google-maps.js
function url() {
  return 'https://www.google.com/maps/@37.386427,-122.0428214,11z';
}

async function action(page) {
  await page.click('text/Hotels');
}

async function back(page) {
  await page.click('[aria-label="Close"]');
}

module.exports = {action, back, url};

Then run it:

memlab run --scenario test-google-maps.js

memlab opens the page in Chromium, takes a heap snapshot after each step, and prints one representative retainer trace per cluster of leaked objects. A retainer trace is the chain of references from a GC root that keeps the leaked object alive.

Commands

Find leaks

| Command | What it does | | --- | --- | | memlab run --scenario <file> | Run a scenario in the browser and find memory leaks | | memlab find-leaks | Find leaks in heap snapshots you already have (--baseline, --target, --final, or --snapshot-dir) | | memlab diff-leaks | Find leaks that are new in a test run compared to a control run | | memlab trace --node-id <id> | Print the retainer trace of one heap object |

Analyze a heap

| Command | What it does | | --- | --- | | memlab analyze <analysis> | Run a heap analysis, for example string, detached-DOM, or unbound-object | | memlab heap --snapshot <file> | Explore one heap snapshot interactively | | memlab view-heap --snapshot <file> | View one heap snapshot in an interactive terminal UI | | memlab anonymize --snapshot <file> --output <file> | Remove user data from a heap snapshot so it can be shared | | memlab snapshot-header --snapshot <file> | Print node and edge counts and the memory needed to analyze a heap snapshot, without parsing it | | memlab class-histogram --snapshot <file> | Count objects and their self size per class (--top, --name-pattern) | | memlab class-diff --baseline <file> --target <file> | Compare objects and self size per class between two heap snapshots, and count objects allocated after the baseline | | memlab class-trend --snapshot-dir <dir> | Track objects per class across a series of snapshots and list the classes that grew at every step | | memlab heap-stats --snapshot <file> | Split a heap snapshot into code, strings, JS arrays, system objects and native memory, and into loaded code vs memory the program allocated | | memlab sliced-strings --snapshot <file> | Find large strings kept alive only by short substrings of them | | memlab weakref-census --snapshot <file> | Count WeakRefs, live vs empty, by what holds them; flags collections that keep entries after their target is gone | | memlab script-census --snapshot <file> | Report the source text of loaded scripts kept in the heap, and scripts kept in memory more than once | | memlab find-objects --snapshot <file> | List objects by class name, node type, retained size or detached state, largest first, with their ids for memlab trace | | memlab dom-audit --snapshot <file> | Count the DOM elements attached to the document, by tag and by repeated element (list virtualization candidates) | | memlab native-contexts --snapshot <file> | Split a heap snapshot by JavaScript realm (page, iframes, detached windows, vm contexts) and show what each detached one holds |

Browser runs

| Command | What it does | | --- | --- | | memlab snapshot --scenario <file> | Run a scenario and take heap snapshots, without finding leaks | | memlab warmup / memlab warmup-and-snapshot | Warm up the app's server before taking snapshots | | memlab measure --scenario <file> | Run a scenario many times to tell real heap growth from run-to-run noise |

Other

| Command | What it does | | --- | --- | | memlab help [command] | List all commands, or print help for one | | memlab version | Show the versions of all installed memlab packages | | memlab get-default-work-dir | Print the directory where results are saved by default | | memlab reset | Reset and re-create memlab's working directories |

Common options:

  • --work-dir <dir>: save the run's snapshots, screenshots, and results here.
  • --headful: show the browser window (headless by default).
  • --device <name>: emulate a device, for example a phone.
  • --chromium-binary <path>: use a specific Chromium build.
  • --silent, --verbose: change how much is printed.

Every command and option is listed in the CLI reference.

Use the CLI from code

run() parses process.argv and dispatches to the matching command, the same way the memlab binary does:

const {run} = require('@memlab/cli');

run();

To drive memlab from a program, the @memlab/api package is usually a better fit: it takes options as objects and returns results instead of printing them.

Add your own heap analysis

memlab analyze loads analyses written as plugins. See @memlab/heap-analysis for how to write one, then pass it with --analysis-plugin.

Online Resources