Skip to content

Instantly share code, notes, and snippets.

@teramako
Created May 19, 2011 08:23
Show Gist options
  • Save teramako/980396 to your computer and use it in GitHub Desktop.
Save teramako/980396 to your computer and use it in GitHub Desktop.
[Vimperator Plugin]about:memory のようなものを出力する
commands.addUserCommand(["memory[reports]"], "show memory reports",
show,
{},
true);
function getMemoryInfo () {
const MRM = Cc["@mozilla.org/memory-reporter-manager;1"].getService(Ci.nsIMemoryReporterManager);
var data = [],
reports = MRM.enumerateReporters();
while (reports.hasMoreElements()) {
var {description, path, memoryUsed} = reports.getNext().QueryInterface(Ci.nsIMemoryReporter);
yield [description, path, memoryUsed];
}
}
function show () {
var x =
<table width="100%">
<tr highlight="Title">
<th>Path</th>
<th>Used</th>
<th>Description</th>
</tr>
</table>
for (let [desc, path, used] in getMemoryInfo()) {
x.appendChild(<tr>
<td>{path}</td>
<td>{util.formatBytes(used, 1, true)}</td>
<td>{desc}</td>
</tr>);
}
liberator.echo(<><style type="text/css"><![CDATA[
table { background-color: white; }
th,td { border: thin solid gray; }
td:nth-child(2) { text-align: right; }
tr:nth-child(odd) { background-color: rgb(240, 248, 255); }
]]></style>
{x}</>, true);
}
// vim: sw=2 ts=2 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment