Performance:Leak Tools:DiffBloatDump
Jump to navigation
Jump to search
This is the basic "monkey see, monkey do" steps for generating trace-malloc diffbloatdump output. You'll need to compile a specially-instrumented build, capture the trace-malloc logs, and then process the logs. Then you'll have output showing what memory was allocated-but-not-freed between the two log capture points.
Creating an instrumented build
- Check out a Mozilla tree as usual
- Check out
mozilla/tools/ - Edit
.mozconfigto enable trace-malloc. I also removed my usual--enable-debug, lest debugging code be causing leaks. EG:
ac_add_options --enable-trace-malloc ac_add_options --disable-optimize --enable-debugger-info-modules
Now build as usual.
Capturing a log
First time:
- Create a clean Firefox profile
- Install RamBack extension
- Disable SafeBrowsing prefs (
Preferences -> Security -> "Tell me if..."), since the nsURLClassifier downloads in the background. - Create a HTML file with buttons to trigger the trace-malloc logging:
<script type="text/javascript">
function dumpLog() {
var filename = window.prompt("Filename to log: ");
if (filename)
TraceMallocDumpAllocations(filename);
}
function startLog() {
TraceMallocEnable();
}
</script>
<button onclick="startLog();">Start Logging</button>
<button onclick="dumpLog();">Dump to Logfile...</button>
The RamBack extension is used to send memory-pressure notifications, which trigger GC and cycle collection. This helps to force things to be deallocated before a taking a sample.
For a session:
- Enter objdir.
- Start Firefox
- Get it to whatever initial state you want to use as a baseline, and with the above HTML page in a tab.
- Click
Tools->Clear Caches(RamBack extension) - Click "Start Logging" button (from HTML above)
- Click "Dump to Logfile" button (from HTML above), enter a filename
- ...do some stuff to cause a leak...
- Click
Tools->Clear Caches(RamBack extension) - Click "Dump to Logfile" button (from HTML above), enter a filename
Processing the log
Assuming the two logs created above are log1 and log2...
- Enter objdir.
- Run
../tools/trace-malloc/diffbloatdump.pl --use-address --depth=50 log1 log2 > tmpfile - Run
../tools/rb/fix-linux-stack.pl tmpfile > logoutput(or fix-macosx-stack.pl)