Performance:Leak Tools: Difference between revisions

Jump to navigation Jump to search
Line 132: Line 132:
==== trace-malloc with diffbloatdump ====
==== trace-malloc with diffbloatdump ====


The best way I know to do this is with [[#Trace-malloc|trace-malloc]]. In a build with trace-malloc enabled you can dump the existing allocations to a file by calling the function TraceMallocDumpAllocations from JavaScript (which is equivalent to calling NS_TraceMallocDumpAllocations from C. The following web page will allow dumping of allocations:
See the documentation on <tt>diffbloatdump.pl</tt> on [https://developer.mozilla.org/en-US/docs/Mozilla/Performance/TraceMalloc MDN].
 
<script type="text/javascript">
    var filename = window.prompt("Filename to log: ");
    if (filename)
      TraceMallocDumpAllocations(filename);
</script>
 
One can then use the script mozilla/tools/trace-malloc/diffbloatdump.pl to compare trace-malloc dumps before and after doing an action that might leak. If there are significant differences, it might be worth examining the call stacks for the destructors of the objects in question to see what is extending their lifetime. (This can be done by examining the unprocessed output of an XPCOM_MEM_REFCNT_LOG, one of the nsTraceRefcnt logs.)  You should use the --use-address argument to diffbloatdump.pl, and then the diff tree can be run through fix_linux_stack.py / fix_macosx_stack.py as appropriate.


== Common leak patterns ==
== Common leak patterns ==
Confirmed users
1,345

edits

Navigation menu