Easy(er) Leak Testing With NTT

David Baron recently put out the call for there to be more leak testing on trunk builds.  We have a number of regressions that we need to find and fix before Firefox 3 goes out the door. The best way to do leak testing has always been to use his excellent leak-gauge script which catches more leaks than the leak monitor extension. Unfortunately the leak-gauge script is not the easiest of beasts to play around with.

Thankfully for some time now Nightly Tester Tools has had the leak-gauge script included in it to hopefully make this process a bit easier. I discovered today that that functionality has actually been broken on trunk builds so make sure you pick up the latest version 1.3b1 if you want to use it (don’t worry i should be pretty stable as betas go). Once installed just go to Tools – Nightly Tester Tools – Analyse Leak Log. Tell it where to find your log and it will create a leak report that you can copy to the clipboard at the touch of a button.

Unfortunately you still need to actually create the leak log, I suggest a script something like this (will need adapting for other platforms):

cp -f nspr.log lastnspr.log
export NSPR_LOG_MODULES=DOMLeak:5,DocumentLeak:5,nsDocShellLeak:5
export NSPR_LOG_FILE=/Users/dave/nspr.log
/Applications/Minefield.app/Contents/MacOS/firefox-bin

Then you can analyse lastnspr.log while still logging the current run. In Firefox you can even set the log analyser as the home page so it automatically loads the last log on startup.

Note that you can’t analyse the log being generated by a currently running app, nor one from a crashed session in an app, both will look hideously leaky. Please be sure to file good memory leak bugs and good leak hunting.