User:Mook:Leak Notes
From MozillaWiki
Notes about leak testing go here.
Environment variables
-
XPCOM_MEM_LEAK_LOG=
file name- dumps a table of leaked (C++) objects to file on shutdown.
-
XPCOM_MEM_BLOAT_LOG=
file name- dumps a table of all objects ever used to file on shutdown. Overrides
XPCOM_MEM_LEAK_LOG
if set.
- dumps a table of all objects ever used to file on shutdown. Overrides
-
XPCOM_MEM_REFCNT_LOG=
file name- logs all AddRef / Release of a given class. Use with
XPCOM_MEM_LOG_CLASSES
, otherwise too much output basically crashes the system.
- logs all AddRef / Release of a given class. Use with
-
XPCOM_MEM_LOG_CLASSES=
class1,
class2...- log only the given classes into
XPCOM_MEM_REFCNT_LOG
- log only the given classes into
-
XPCOM_MEM_LOG_OBJECTS=
serial1,
serial2...- log only objects with the given serial number (as output by previous refcnt logs). Good luck getting things deterministic enough for this to be useful.
mozilla.org has more stuff, but they do not seem to be as useful (on Win32).
Scripts (for refcnt logs)
- Run the target app with
XPCOM_MEM_REFCNT_LOG
to generate data to look at. - Run
find-leakers.pl < file
to find the addresses of the leaked objects. - Run
make-tree.pl --object address --ignore-balanced < file > output file
to build a tree of the allocations to stare at. Note that here might get confused if the lines have DOS-style line endings.
Notes on the tree generated
- On
createInstance
calls, it's shown as AddRef / AddRef / Release with the first and third being a temporarynsCOMPtr<nsISupports>
that can be discarded.
TODO: see if I can paste the leak script I'm using.