Changes

Jump to: navigation, search

Performance:Leak Tools

23 bytes removed, 22:02, 4 June 2012
update broken LXR links to use MXR
==== leak-gauge ====
Leak gauge is a script (available as a [http://lxrmxr.mozilla.org/mozilla-central/source/tools/footprint/leak-gauge.pl?raw=1 perl script] or as [http://lxrmxr.mozilla.org/mozilla-central/source/tools/footprint/leak-gauge.html?rawforce=1 HTML and JavaScript that must be run from a local file]) that post-processes an log taken by setting environment variables in a release build. It is designed to assist in detecting what leaks of large object graphs occur during normal browsing activity. The logging can be run (as described in the script) during normal browsing without significant overhead. Then the script can be run to provide information about the documents, window objects, and docshells that leaked. See [http://www.squarefree.com/2006/01/13/memory-leak-detection-tool/ Jesse Ruderman's blog entry] for more details including a list of other links.
You can find also how-to documentation at [[QA:Home_Page:Firefox_3.0_TestPlan:Leaks:LeakTesting-How-To]].
==== trace-refcnt and the [http://mozilla.org/performance/refcnt-balancer.html refcount balancer] ====
The refcount balancer consists of the [http://lxrmxr.mozilla.org/seamonkeymozilla-central/source/xpcom/base/nsTraceRefcntImpl.cpp nsTraceRefcnt] code in [http://lxr.mozilla.org/seamonkey/source/xpcom/base/ mozilla/xpcom/base/] and the perl scripts in [http://lxrmxr.mozilla.org/mozilla-central/source/tools/rb/ mozilla/tools/rb/]. It works by instrumenting refcounting, so every AddRef and Release method created using NS_IMPL_ISUPPORTSn and variants, NS_IMPL_ADDREF, or NS_IMPL_RELEASE is automatically instrumented. It also logs information for non-refcounted objects instrumented using the MOZ_COUNT_CTOR and MOZ_COUNT_DTOR macros.
Because it is based on instrumentation, it is not reliable for gathering aggregate statistics. (In spite of this, it is used for the "RLk" leak stats on tinderbox, so the trace-malloc-based "Lk" numbers are more meaningful.) However, it is by far the best tool we have for ''debugging'' leaks of reference counted objects, which are the leaks in Mozilla that can entrain the largest object graphs.
==== Trace-malloc ====
The trace-malloc code consists of the nsTraceMalloc code in [http://lxrmxr.mozilla.org/mozilla-central/source/tools/trace-malloc/lib/ mozilla/tools/trace-malloc/lib/] and the perl scripts and trace-malloc readers in [http://lxrmxr.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 built by checking out mozilla/tools/trace-malloc/ and building with --enable-trace-malloc.
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]].
Canmove, confirm
1,584
edits

Navigation menu