Skip to content

Instantly share code, notes, and snippets.

@958
Created July 7, 2011 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 958/1068682 to your computer and use it in GitHub Desktop.
Save 958/1068682 to your computer and use it in GitHub Desktop.
[keysnail]keysnail の prompt に about:memory を表示する
ext.add('show-memory-report', function(ev, arg) {
function addFigure(str) {
var num = new String(str).replace(/,/g, "");
while(num != (num = num.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
return num;
}
function getMemoryReports() {
let mrm = Cc["@mozilla.org/memory-reporter-manager;1"].getService(Ci.nsIMemoryReporterManager);
let e = mrm.enumerateReporters();
while (e.hasMoreElements()) {
let {path, description, memoryUsed} = e.getNext().QueryInterface(Ci.nsIMemoryReporter);
yield [path, description, addFigure(memoryUsed)];
}
}
prompt.selector({
message : 'pattern:',
initialInput: arg,
collection : [i for (i in getMemoryReports())],
header : ['path', 'description', 'size'],
width : [30, 60, 10],
flags : [0, 0, IGNORE],
stylist : function (args, n, current) {
let style = '';
if (n == 2) style += 'padding-right: 0.5em; text-align: right;';
return style;
},
actions : [function(){}],
});
}, 'about:memory');
@958
Copy link
Author

958 commented Jul 7, 2011

ext.exec('show-memory-report', 'malloc', ev);
等とすることで、初期表示を絞り込み可能

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment