Skip to content

Memory Leak Debugging

Thomas Barber edited this page Aug 4, 2022 · 2 revisions

There are a couple of ways of debugging memory leaks.

Valgrind

Valgrind is a heavy duty memory analysis tool.

Installing

Easiest is to install the package manager version of valgrind. There is a significant slowdown with valgrind, so it's best to start memory leak analysis with Spidermonkey standalone, before trying out the browser.

sudo apt install valgrind

Building

Add a couple of additional options to your .mozconfig:

ac_add_options --disable-jemalloc
ac_add_options --disable-strip
ac_add_options --enable-valgrind
ac_add_options --enable-optimize="-g -O2"
ac_add_options --disable-sandbox

Running

Then run with the following options:

G_SLICE=always-malloc valgrind --leak-check=full --smc-check=all-non-file --vex-iropt-register-updates=allregs-at-mem-access --show-mismatched-frees=no --log-file="valgrind.log" --read-inline-info=yes obj-tf-release/dist/bin/foxhound

And search the log file for Taint-related memory leaks.

Helpful Links

This page is based on the following firefox guides: