Performance:Leak Tools: Difference between revisions

Jump to navigation Jump to search
Line 114: Line 114:
=== Leak tools for simple objects and summary statistics ===
=== Leak tools for simple objects and summary statistics ===


==== Trace-malloc ====
==== TraceMalloc ====


The trace-malloc code consists of the nsTraceMalloc code in [http://mxr.mozilla.org/mozilla-central/source/tools/trace-malloc/lib/ mozilla/tools/trace-malloc/lib/] and the perl scripts and trace-malloc readers in [http://mxr.mozilla.org/mozilla-central/source/tools/trace-malloc/ mozilla/tools/trace-malloc/]. It works by overriding / hooking into malloc and free (and related functions) and logging all calls, with stacks. It is probably the best tool we currently have for gathering aggregate memory usage statistics. It is generally more useful for bloat measurement than leak measurement, but it can be used to find leaks, including leaks of objects not instrumented for trace-refcnt. It works on Windows, Linux (x86), and Mac (PPC and Intel).  It can be used by building with --enable-trace-malloc.
See the documentation on TraceMalloc on [https://developer.mozilla.org/en-US/docs/Mozilla/Performance/TraceMalloc MDN].
 
Trace malloc slows down the browser a bit (maybe 3x?) at runtime on Linux and Mac, but by a lot more on Windows.  However, the stacks on Linux and Mac require [[#Post-processing_of_stack_traces|post-processing]].
 
Generate a trace-malloc dump by building with <code>ac_add_options --enable-trace-malloc</code> and then passing <code>--trace-malloc FILENAME</code> when you start Firefox.


==== Valgrind, LSAN and Apple tools ====
==== Valgrind, LSAN and Apple tools ====
Confirmed users
1,345

edits

Navigation menu