
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
memlab is a framework that analyzes memory and finds memory leaks in JavaScript applications.
memlab is an E2E testing and analysis framework for finding JavaScript memory leaks in Chromium. The CLI Toolbox and library provide extensible interfaces for analyzing heap snapshots taken from Chrome/Chromium, Node.js, Hermes, and Electron.js.
Install the CLI
npm install -g memlab
To find memory leaks in Google Maps, you can create a scenario file defining how
to interact with the Google Maps, let's name it test-google-maps.js
:
// initial page load url: Google Maps
function url() {
return 'https://www.google.com/maps/@37.386427,-122.0428214,11z';
}
// action where we want to detect memory leaks: click the Hotels button
async function action(page) {
// puppeteer page API
await page.click('button[aria-label="Hotels"]');
}
// action where we want to go back to the step before: click clear search
async function back(page) {
// puppeteer page API
await page.click('[aria-label="Clear search"]');
}
module.exports = {action, back, url};
Now run memlab with the scenario file, memlab will interact with the web page and detect memory leaks with built-in leak detectors:
memlab run --scenario test-google-maps.js
If you want to use a self-defined leak detector, add a filterLeak
callback
in the scenario file. filterLeak
will be called for every unreleased heap
object (node
) allocated by the target interaction.
function filterLeak(node, heap) {
// ... your leak detector logic
// return true to mark the node as a memory leak
};
heap
is the graph representation of the final JavaScript heap snapshot.
For more details, view the doc site.
View which object keeps growing in size during interaction in the previous run:
memlab analyze unbound-object
Analyze pre-fetched v8/hermes .heapsnapshot
files:
memlab analyze unbound-object --snapshot-dir <DIR_OF_SNAPSHOT_FILES>
Use memlab analyze
to view all built-in memory analyses. For extension, view the doc site.
View retainer trace of a particular object:
memlab trace --node-id <HEAP_OBJECT_ID>
Use memlab help
to view all CLI commands.
Use the memlab
npm package to start a E2E run in browser and detect memory leaks.
const memlab = require('memlab');
const scenario = {
// initial page load url
url: () => 'https://www.google.com/maps/@37.386427,-122.0428214,11z',
// action where we want to detect memory leaks
action: async (page) => await page.click('button[aria-label="Hotels"]'),
// action where we want to go back to the step before
back: async (page) => await page.click('[aria-label="Clear search"]'),
}
memlab.run({scenario});
FAQs
memlab is a framework that analyzes memory and finds memory leaks in JavaScript applications.
The npm package memlab receives a total of 82,723 weekly downloads. As such, memlab popularity was classified as popular.
We found that memlab demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.