memlab
Analyzes JavaScript heap and finds memory leaks in browser and node.js
Define Your Test
Define E2E test scenarios on browser interaction:
// test.jsfunction url() {return 'https://www.google.com/maps/place/Silicon+Valley,+CA/';}async function action(page) {await page.click('text/Hotels');}async function back(page) {await page.click('[aria-label="Close"]');}module.exports = {action, back, url};
Run memlab in CLI
Find memory leaks with the custom E2E test scenario:
Support memory analyses for the previous browser test:$ memlab run --scenario test.js
# Analyze duplicated string in heap$ memlab analyze string# Check unbound object growth$ memlab analyze unbound-object# Get shapes with unbound growth$ memlab analyze unbound-shape# Discover more memory analyses$ memlab analyze -h
Programming API
Memory analysis for JavaScript heap snapshots:
const {findLeaks, takeSnapshots} = require('@memlab/api');async function test() {const scenario = {url: () => 'https://www.facebook.com',};const result = await takeSnapshots({scenario});const leaks = findLeaks(result);// ...}