Performance:Leak Tools: Difference between revisions

add a few sections
(add a few sections)
Line 7: Line 7:
Because it is based on instrumentation, it is not reliable for gathering aggregate statistics. (In spite of this, it is currently used for the leak stats on tinderbox, although a trace-malloc based replacement is in development.) 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.
Because it is based on instrumentation, it is not reliable for gathering aggregate statistics. (In spite of this, it is currently used for the leak stats on tinderbox, although a trace-malloc based replacement is in development.) 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.


These tools on Windows, Mac (PPC and Intel), and Linux (x86), although  nsCOMPtr logging doesn't work on Windows (?) and Mac and Linux stack traces require some post-processing (see below). In optimized builds they can be built with --enable-logrefcnt.
These tools work best on Linux, although they work reasonably well on Mac (except that nsCOMPtr logging doesn't work). Some people claim to have seen them work on Windows, but I haven't been able to get them to work. They are built by default in debug builds. In Linux optimized builds they can be built with --enable-logrefcnt. In Windows optimized builds they can be built by setting FORCE_BUILD_REFCNT_LOGGING=1 (?).


See below for a detailed description of how to use the refcount balancer effectively.
See below for a detailed description of how to use the refcount balancer effectively.
Line 13: Line 13:
=== Trace-malloc ===
=== Trace-malloc ===


The trace-malloc code consists of the nsTraceMalloc code in [http://lxr.mozilla.org/mozilla/source/tools/trace-malloc/lib/ mozilla/tools/trace-malloc/lib/] and the perl scripts and trace-malloc readers in [http://lxr.mozilla.org/mozilla/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. 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.
The trace-malloc code consists of the nsTraceMalloc code in [http://lxr.mozilla.org/mozilla/source/tools/trace-malloc/lib/ mozilla/tools/trace-malloc/lib/] and the perl scripts and trace-malloc readers in [http://lxr.mozilla.org/mozilla/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. It works on Linux and is close to working on Windows. On Linux it can be built by checking out mozilla/tools/trace-malloc/ and building with --enable-trace-malloc. On Windows it can be built by checking out mozilla/tools/trace-malloc/ and (?).


'''Update''' (2003-06-16): There is a new trace-malloc tool, leaksoup, that is useful for finding leaks. See below for more information on how to use it.
'''Update''' (2003-06-16): There is a new trace-malloc tool, leaksoup, that is useful for finding leaks. See below for more information on how to use it.
Line 84: Line 84:


== Getting symbol information for system libraries ==
== Getting symbol information for system libraries ==
=== Windows ===
Setting the environment variable <code>_NT_SYMBOL_PATH</code> to something like <code>symsrv*symsrv.dll*f:\localsymbols*http://msdl.microsoft.com/download/symbols</code> as described in [http://support.microsoft.com/kb/311503 Microsoft's article].  This needs to be done when running, since we do the address to symbol mapping at runtime.
=== Linux ===
Many Linux distros provide packages containing external debugging symbols for system libraries.  fix-linux-stack.pl uses this debugging information (although it does not verify that they match the library versions on the system).
For example, on Fedora, these are in *-debuginfo RPMs (which are available in yum repositories that are disabled by default, but easily enabled by editing the system configuration).


== Leak statistics on tinderbox ==
== Leak statistics on tinderbox ==
canmove, Confirmed users, Bureaucrats and Sysops emeriti
1,334

edits