Skip to main content

Why memlab

One of the challenges with building a single-page application (SPA) like Facebook.com is to test and check for memory leaks at scale. Manually triggering, finding, and analyzing memory leaks is tedious and inefficient, especially considering the number of changes that go live continuously. We built memlab to automate and ease the process in continuous tests.

Features

Memlab is a memory testing framework for JavaScript. It supports defining a test scenario (using Puppeteer API) that teaches Memlab how to interact with your Single-page Application (SPA), Memlab can handle the rest for memory leak checking automatically:

  • Interact with browser and take JavaScript heap snapshots
  • Analyze heap snapshots and filter out memory leaks
  • Aggregate and group similar memory leaks
  • Generate retainer traces for memory debugging

For more details on how memlab finds memory leaks, please check out this link.


Other features provided by memlab:

  • Object-oriented heap traversing API - Supports self-defined memory leak detector and programmatically analyzing JS heap snapshots taken from Chromium-based browsers, Node.js, Electron.js, and Hermes.
  • Memory CLI toolbox - Built-in CLI toolbox and APIs for finding memory optimization opportunities (not necessarily memory leaks)
  • Memory assertions in Node.js - Enables unit test or running node.js program to take a heap snapshot of its own state, do self memory checking, and write memory assertions (doc)

Trying out memlab:

Read this engineering blog post on how MemLab is used at Meta.