Package Exports
- memlab-analyzer
- memlab-analyzer/lib/analyze-leaks.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (memlab-analyzer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
memlab-analyzer
CLI and utilities for analyzing memory leaks with MemLab and Playwright.
Installation
To install the CLI globally:
npm install -g memlab-analyzerTo install as a dependency in your project:
npm install memlab-analyzerUsage
CLI
Analyze memory leaks from a directory of MemLab snapshots:
analyze-leaks [snapshotDir] [outputFormat] [outputFile]snapshotDir: Directory containing MemLab snapshots (default:./memlab-snapshots)outputFormat:console,json, ortext(default:console)outputFile: Base name for output file (default:memlab-report)
As a Library
To use memlab-analyzer as a library in your project:
const { analyzeMemoryLeaks, formatBytes, generateTextReport } = require("memlab-analyzer");
// Example:
(async () => {
const leaks = await analyzeMemoryLeaks("./memlab-snapshots", "console");
if (leaks.length) {
console.log("Leaks found:", leaks);
} else {
console.log("No leaks detected.");
}
})();API
When you require("memlab-analyzer"), you get an object with the following functions:
analyzeMemoryLeaks(workDir, outputFormat, outputFile): Analyzes memory snapshots.workDir(string, optional): Directory with Memlab snapshots. Default:./memlab-snapshots.outputFormat(string, optional):console,json, ortext. Default:console.outputFile(string, optional): Base name for report files (ifjsonortext). Default:memlab-report.- Returns: Promise resolving to an array of detected leaks.
formatBytes(bytes, decimals): Utility to format byte counts into human-readable strings (KB, MB, etc.).generateTextReport(leaks, workDir): Generates a string report from leak data.
Example
analyze-leaks ./memlab-snapshots text my-reportLicense
MIT
Contributing
This project uses Changesets to manage releases. If you are contributing code that you believe should trigger a new version of the package (e.g., bug fixes, new features, breaking changes), please include a changeset with your pull request.
To add a changeset:
- After making your code changes, run the following command:
npm run changeset - Follow the prompts from the Changesets CLI to select the type of change (patch, minor, or major) for each modified package (in this case, just
memlab-analyzer) and write a brief description of your changes. This description will be used in the changelog. - Commit the generated changeset file (located in the
.changesetdirectory) along with your code changes.
This helps automate the versioning and changelog generation process.