MozillaQualityAssurance:Home Page:Firefox 3.0 TestPlan:Leaks:LeakTesting-How-To

From MozillaWiki
Jump to navigation Jump to search

Firefox 3 Leak Testing How-To

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.

Builds

The Debug Builds for Leak Testing need to be build individually.

Debug Builds (for Leak Testing) are much bigger then normal optimized Firefox Builds. A Debug Leak Testing can be need up to 1,2 GB Disk Space.

There is right now no provided Leak Testing Build on the Mozilla FTP Server.

For Building and Running Debug Builds please see the Build Documentation provided on developer.mozilla.org. There are Instruction available for Windows, Linux and Mac OSX.

If you build a Debug Build, you need to have trace-malloc activated in this builds. The .mozconfig file we use can be found for Windows XP, Mac OS 10.4 and Linux here.

Running a Leak Testing Build

Open a Terminal window (or xterm or Gnome Terminal) and enter:

export XPCOM_MEM_LEAK_LOG=~/tmp/leak.log

Note that the directory you drop your leak.log into should already exist, so if it's not there, please create it first.

Run the debug build of firefox creating a new profile. For mac, this would be:

cd /location of your debug build/firefox-debug/dist/ 
FirefoxDebug.app/Contents/MacOS
./firefox-bin -P

linux (and when you use Mozilla Build on Windows) is:

cd /location of your debug build/firefox-debug/dist/bin
./firefox -P


At the end of the run, the contents of ~/tmp/leak.log should have something in it.

How do i know when i have found a leak ?

When you run Firefox like described above and quit Firefox later you get a Statistic in the Console where you have started Firefox.

If no leak was found the output looks like the following:

nsStringStats
=> mAllocCount:          79737
=> mReallocCount:         4990
=> mFreeCount:           79737
=> mShareCount:          58374
=> mAdoptCount:           4593
=> mAdoptFreeCount:       4593

and the leak.log stays empty.

When you run into a Memory leak the Stats look as example like this:

nsStringStats
=> mAllocCount:          32807
=> mReallocCount:         3994
=> mFreeCount:           32805  --  LEAKED 2 !!!
=> mShareCount:          30349
=> mAdoptCount:           3524
=> mAdoptFreeCount:       3524

When you run into a leak you see also a lot of information in the leaks.log. This log is needed for debugging and fixing the leak.

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
    • 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