Thanks to visit codestin.com
Credit goes to facebook.github.io

Skip to main content

memlab

Analyzes JavaScript heap and finds memory leaks in browser and node.js

Define Your Test

Define E2E test scenarios on browser interaction:

// test.js
function 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:

$ memlab run --scenario test.js
Support memory analyses for the previous browser test:
# 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);
// ...
}

Who's using memlab?