gitmyhub

fuite

JavaScript ★ 4.6k updated 10mo ago

A tool for finding memory leaks in web apps

A command-line tool that automatically finds memory leaks in web apps by opening Chrome, clicking through your pages repeatedly, and reporting which JavaScript objects, event listeners, DOM nodes, or collections keep growing with each pass.

JavaScriptNode.jsPuppeteerChromesetup: easycomplexity 2/5

fuite (French for "leak") is a command-line tool that helps developers find memory leaks in web applications. Memory leaks happen when a browser holds onto data it should have freed, causing pages to grow slower or crash over time. This tool tries to catch those problems automatically, without requiring you to manually dig through browser profiling tools.

You point fuite at a URL, and it opens Chrome in the background using Puppeteer, a browser automation library. By default, it finds links on your page, clicks each one, then hits the browser back button, and repeats this seven times. After each pass, it takes a snapshot of what is in memory. If the same types of objects keep growing with each repetition (exactly 7, 14, or 21 new instances), that is a strong signal that something is leaking rather than just temporarily allocated. Repeating a small prime number of times helps filter out coincidental noise.

It looks for four categories of leaks: JavaScript objects captured through browser heap snapshots, event listeners that were never removed, DOM nodes still attached to the page, and collections like arrays, maps, and sets that keep growing without being cleared. After a run, it prints a summary to the terminal showing what leaked and by how much.

For more complex apps, you can write a custom scenario file in JavaScript. The file exports functions (setup, iteration, teardown, and waitForIdle) that let you describe exactly what action to repeat during each test. An iteration might open a modal and close it, show a tooltip and dismiss it, or navigate to a page and come back. The only requirement is that the page ends up in the same state it started in, because multi-page apps do not accumulate memory the same way single-page apps do.

An output flag saves a full JSON report with additional detail, including which line of code registered a leaking event listener. Other options let you adjust the number of iterations, pass extra arguments to Chrome, or run in debug mode.

Where it fits