MozillaQualityAssurance:Home Page:Firefox 3.0 TestPlan:Leaks:LeakTesting-How-To
Firefox 3 Leak Testing How-To
Note: this is a draft !
Introduction
Mozilla QA uses Trace Malloc Debug Build to test Firefox Components and Extensions for leaks. One part of this testing is manual testing. You can find the QA Firefox 3 Leak Testing Testplan here.
Leak Gauge
For testing Firefox and Extensions for Memory we recommend "Leak Gauge" developed by David Baron. Leak Gauge is designed to help testers isolate and simplify testcases for many classes of leaks (those that involve large graphs of core data structures) in Mozilla-based browsers. It is designed to print information about what has leaked by processing a log taken while running the browser. Such a log can be taken over a long session of normal browsing and then the log can be processed to find sites that leak. Once a site is known to leak, the logging can then be repeated to figure out under what conditions the leak occurs.
Leak Gauge is easy to use and you don't need to download any additional Software or Tool (like needed for Debug Builds).
Leak Gauge will create a leak log file. You can upload this Log File here to get a analysis if you have run into a memory leak. There are plans to move this upload later to a better location like AMO.
Using Leak Gauge
As mentioned before, you don't need to install addional software to run Leak Gauge, however some simple tests are needed to run Leak Gauge and to get the Leak Log.
1. Setting up the Environment Variable:
The way to create the log is to set the environment variables:
NSPR_LOG_MODULES=DOMLeak:5,DocumentLeak:5,nsDocShellLeak:5,NodeInfoManagerLeak:5 NSPR_LOG_FILE=nspr.log (or any other filename of your choice)
in your shell and then run the program.
- In a Windows command prompt, set environment variables with
set VAR=value
- In an sh-based shell such as bash, set environment variables with
export VAR=value
- In a csh-based shell such as tcsh, set environment variables with
setenv VAR value
As example for Windows, this should look like:
- 1. Start the Windows Command Prompt (Start -> Run -> cmd.exe or Start -> Programs -> Accessories -> Command Prompt
- 2. Set the env Variable:
C:\>set NSPR_LOG_MODULES=DOMLeak:5,DocumentLeak:5,nsDocShellLeak:5,NodeInfoManagerLeak:5
and now you need to define the Location of the Leak Log File:
C:\>set NSPR_LOG_FILE=c:\leak1.log
(or any other location/file name of your choice)
- 3. Start Firefox and your leak log will be created.
Note:
- When you test Firefox or your Extensions for leaks, you need to type the command above every time you start the Console/Terminal
- Once you have this log from a complete run of the browser, you have
to exit; otherwise it will look like everything leaked
- Every time you start Firefox after you have defined the environment variables, your existing leak log will be overwritten. So if you want to reproduce a leak, or when you want to save a leak log, you need to change the filename (like from leak1.log to leak2.log) next time before you run Firefox.
See also the steps for testing for more Information.
The Leak Gauge Leak Log File
You have setup the environment variables and you got a leak.log, Fine ! Now you need to upload this leak log on this site.
After you have uploaded a leak log, the site will display the output of the results from the leak log, which will tell you which of certain core objects leaked and the URLs associated with those objects.
A normal output, without any leaking object / memory leak should look like:
Results of processing log leak.log : Summary: 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
Debug Builds
You can also use debug builds for leak testing. Building and Running a Debug Build is more complex then using Leak Gauge. If you interested in running Leak Test Debug Builds you can find here more information.
Leak Testing - Example of testing steps for Extension Testing
When you found a leak, its important to have some steps to reproduce, so developers can reproduce this leak and also for verifying a fixed leak bug.
As example here are the steps to reproduce from Bug 411576.
- First create a new Firefox Profile to ensure nothing else from a used profile cause a leak. Start your Leak Debug as described.
- Install a Extension and Restart Firefox
- After the Restart - Quit Firefox to make sure the Extension does not leak after installation
- When no memory leak was detected play a little with the extension to make sure the extension does not leak on specific steps to reproduce.
Some examples for in-detail testing of extensions:
- Try out features of the Extension (like Buttons, Options, etc). After you have done this, quit firefox to check the leak.log
- Go into the Extension Manager and check if the Firefox Extension Manager leaks when the Extension is installed
- Use the Extension Options Button in the Extension Manager (see Bug 412136.
- When a memory leak was detected save the leak.log and start Firefox again to check if the extension leaks only the first time after installation, or if the extension leak in general when installed