Last active
August 29, 2015 14:26
-
-
Save zbraniecki/62003182ccb946fd0238 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dbg = null; | |
Components.utils.forceGC(); | |
Components.utils.import("resource://gre/modules/devtools/Loader.jsm"); | |
Debugger = devtools.require("Debugger"); | |
dbg = devtools.require("devtools/server/actors/utils/make-debugger")({ | |
findDebuggees: dbg => dbg.findAllGlobals(), | |
shouldAddNewGlobalAsDebuggee: () => true | |
}); | |
dbg.addDebuggees(); | |
console.log(dbg); | |
dbg.memory.allocationSamplingProbability = 1; | |
dbg.memory.trackingAllocationSites = true; | |
devtools.require("sdk/timers").setTimeout(() => { | |
console.log("====================================================================================="); | |
console.time("census"); | |
let census = dbg.memory.takeCensus({ | |
breakdown: { | |
by: "allocationStack", | |
then: { by: "count", count: true, bytes: true }, | |
noStack: { by: "count", count: true, bytes: true } | |
}, | |
}); | |
dbg.memory.trackingAllocationSites = false; | |
console.timeEnd("census"); | |
console.log(census); | |
console.log("====================================================================================="); | |
let i = 0; | |
var results = []; | |
var totalBytes = 0; | |
var bytesExplained = 0; | |
census.forEach((v, k) => { | |
if (k.toString().indexOf('l20n.js') === -1) { | |
return; | |
} | |
totalBytes += v.bytes; | |
results.push({stack: k.toString(), value: v}); | |
}); | |
results.sort(function(a, b) { | |
return b.value.bytes - a.value.bytes; | |
}); | |
results.slice(0, 30).forEach(res => { | |
console.log(res.stack) | |
console.log(res.value); | |
console.log(); | |
bytesExplained += res.value.bytes; | |
}); | |
console.log('Total bytes: ' + totalBytes); | |
console.log('Top 30 allocations explains: ' + bytesExplained + ' bytes'); | |
}, 2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment