{"library":"memlab","title":"MemLab - JavaScript Memory Leak Detection Framework","description":"MemLab is an end-to-end testing and analysis framework for identifying JavaScript memory leaks and optimization opportunities. Version 2.0.1 is the latest stable release, actively maintained by Meta. It provides automated browser memory leak detection using Puppeteer, a heap snapshot analysis API for Node.js/Electron/Hermes, and CLI tools for memory debugging. Key differentiators: supports custom leak detectors, object-oriented heap traversing, and integrates with unit testing. MemLab goes beyond simple heap dump analysis by automatically comparing snapshots and filtering leaks with retainer traces.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install memlab"],"cli":{"name":"memlab","version":null}},"imports":["import memlab from 'memlab'","import { IScenario } from 'memlab'","import { takeHeapSnapshot } from 'memlab'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import memlab from 'memlab';\nimport fs from 'fs';\n\n// Define a scenario as an object with url, action, back functions\nconst scenario = {\n  url: () => 'https://example.com',\n  async action(page) {\n    await page.click('button#load-more');\n  },\n  async back(page) {\n    await page.click('button#reset');\n  }\n};\n\nasync function runLeakDetection() {\n  // Run leak detection with default options\n  const result = await memlab.run(scenario);\n  console.log(`Leaks found: ${result.leaks.length}`);\n  for (const leak of result.leaks) {\n    console.log(`Retained size: ${leak.retainedSize}`);\n  }\n}\n\nrunLeakDetection().catch(console.error);","lang":"typescript","description":"Demonstrates using MemLab's programmatic API to define a scenario and run browser memory leak detection.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}