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

From MozillaWiki
Jump to: navigation, search

Testing Extensions and Firefox for Memory Leaks with a Debug Build

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.

You can download debug builds from the Mozilla FTP Server. Select the wanted branch and operating system from the tinderbox-builds directory and also open the folder in it. Download and unzip the * build.

For Building and Running Debug Builds please see the Build Documentation provided on 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/
./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:

=> 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:

=> 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.