Created
July 7, 2011 00:40
-
-
Save 958/1068682 to your computer and use it in GitHub Desktop.
[keysnail]keysnail の prompt に about:memory を表示する
This file contains hidden or 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
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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ext.exec('show-memory-report', 'malloc', ev);
等とすることで、初期表示を絞り込み可能