Leak Gauge

Leak Gauge is a tool that can be used to detect certain kinds of leaks in Gecko, including those involving documents, window objects, and docshells. It has two parts: (a) instrumentation in Gecko that produces a log file, and (b) a script to post-process the log file.

Getting a log file

To get a log file, run the browser with the following environment variables set.

NSPR_LOG_FILE=nspr.log     # or any other filename of your choice

This will overwrite any existing file called nspr.log. The browser will run with negligible slowdown. You must exit the browser before post-processing the log file or the results will be unreliable.

Post-processing a log file

Post-process the log file with tools/leak-gauge/leak-gauge.pl or tools/leak-gauge/leak-gauge.html.

If there are no leaks, output will look like the following.

Results of processing log leak.log :
Leaked 0 out of 11 DOM Windows
Leaked 0 out of 44 documents
Leaked 0 out of 3 docshells
Leaked content nodes in 0 out of 0 documents

If there are leaks, output will look like the following.

Results of processing log leak2.log :
Leaked outer window 2c6e410 at address 2c6e410.
Leaked outer window 2c6ead0 at address 2c6ead0.
Leaked inner window 2c6ec80 (outer 2c6ead0) at address 2c6ec80.
Leaked 13 out of 15 DOM Windows
Leaked 35 out of 46 documents
Leaked 4 out of 4 docshells
Leaked content nodes in 42 out of 53 documents

If you see such a results, please file a bug.

Document Tags and Contributors

Contributors to this page: yfdyh000, nnethercote
Last updated by: yfdyh000,