Skip to content

Instantly share code, notes, and snippets.

@fitzgen
Created July 27, 2015 22:14
Show Gist options
  • Save fitzgen/80a5c15baacb96541807 to your computer and use it in GitHub Desktop.
Save fitzgen/80a5c15baacb96541807 to your computer and use it in GitHub Desktop.
record allocations for 5s -> take a census
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 }
},
});
console.timeEnd("census");
console.log(census);
console.log("=====================================================================================");
let i = 0;
census.forEach((v, k) => {
if (i++ >= 10)
return;
console.log(k.toString())
console.log(v);
console.log();
})
}, 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment