author | Nick Fitzgerald <fitzgen@gmail.com> |
Thu, 23 Apr 2015 16:26:00 -0400 | |
changeset 241150 | ee6125ec034ce36e9467e0ce529dc4c1e8fb15fe |
parent 241149 | 0a899ed1487bc0b3c29a447d738bc73b96c1a406 |
child 241151 | 1ead03b757447149be3c61fac910506dbc99d400 |
push id | 59036 |
push user | cbook@mozilla.com |
push date | Mon, 27 Apr 2015 10:37:48 +0000 |
treeherder | mozilla-inbound@ad388474898c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jryans |
bugs | 1137527 |
milestone | 40.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/toolkit/devtools/server/actors/memory.js +++ b/toolkit/devtools/server/actors/memory.js @@ -57,31 +57,49 @@ types.addDictType("AllocationsRecordingO * An actor that returns memory usage data for its parent actor's window. * A tab-scoped instance of this actor will measure the memory footprint of its * parent tab. A global-scoped instance however, will measure the memory * footprint of the chrome window referenced by the root actor. */ let MemoryActor = protocol.ActorClass({ typeName: "memory", + /** + * The set of unsolicited events the MemoryActor emits that will be sent over + * the RDP (by protocol.js). + */ + events: { + // Same format as the data passed to the + // `Debugger.Memory.prototype.onGarbageCollection` hook. See + // `js/src/doc/Debugger/Debugger.Memory.md` for documentation. + "garbage-collection": { + type: "garbage-collection", + data: Arg(0, "json"), + }, + }, + get dbg() { if (!this._dbg) { this._dbg = this.parent.makeDebugger(); } return this._dbg; }, initialize: function(conn, parent, frameCache = new StackFrameCache()) { protocol.Actor.prototype.initialize.call(this, conn); this.parent = parent; this._mgr = Cc["@mozilla.org/memory-reporter-manager;1"] .getService(Ci.nsIMemoryReporterManager); this.state = "detached"; this._dbg = null; this._frameCache = frameCache; + + this._onGarbageCollection = data => + events.emit(this, "garbage-collection", data); + this._onWindowReady = this._onWindowReady.bind(this); events.on(this.parent, "window-ready", this._onWindowReady); }, destroy: function() { events.off(this.parent, "window-ready", this._onWindowReady); @@ -89,19 +107,24 @@ let MemoryActor = protocol.ActorClass({ if (this.state === "attached") { this.detach(); } protocol.Actor.prototype.destroy.call(this); }, /** * Attach to this MemoryActor. + * + * This attaches the MemoryActor's Debugger instance so that you can start + * recording allocations or take a census of the heap. In addition, the + * MemoryActor will start emitting GC events. */ attach: method(expectState("detached", function() { this.dbg.addDebuggees(); + this.dbg.memory.onGarbageCollection = this._onGarbageCollection; this.state = "attached"; }, `attaching to the debugger`), { request: {}, response: { type: "attached" } }),