Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Latest commit

 

History

History
159 lines (110 loc) · 5.5 KB

memory.md

File metadata and controls

159 lines (110 loc) · 5.5 KB

Table of Contents

Memory

Extends Actor

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.

This actor wraps the Memory module at devtools/server/performance/memory.js and provides RDP definitions.

Parameters

  • client
  • name

attach

Attach to this MemoryBridge.

This attaches the MemoryBridge's Debugger instance so that you can start recording allocations or take a census of the heap. In addition, the MemoryBridge will start emitting GC events.

Returns Promise request response

detach

Detach from this MemoryBridge.

Returns Promise request response

getState

Gets the current MemoryBridge attach/detach state.

Returns Promise.String attach/detach state

takeCensus

Take a census of the heap. See js/src/doc/Debugger/Debugger.Memory.md for more information.

Returns Promise request response

startRecordingAllocations

Start recording allocation sites.

Parameters

  • options

Returns Promise request response

stopRecordingAllocations

Stop recording allocation sites.

Returns Promise request response

getAllocationsSettings

Return settings used in startRecordingAllocations for probability and maxLogLength. Currently only uses in tests.

Returns Promise.Object allocation settings

getAllocations

Get a list of the most recent allocations since the last time we got allocations, as well as a summary of all allocations since we've been recording.

Returns Object An object of the form: { allocations: [<index into "frames" below>, ...], allocationsTimestamps: [ <timestamp for allocations[0]>, <timestamp for allocations[1]>, ... ], allocationSizes: [ <bytesize for allocations[0]>, <bytesize for allocations[1]>, ... ], frames: [ { line: , column: , source: , functionDisplayName: <this frame's inferred function name function or null>, parent: <index into "frames"> }, ... ], }The timestamps' unit is microseconds since the epoch.Subsequent getAllocations request within the same recording and tab navigation will always place the same stack frames at the same indices as previous getAllocations requests in the same recording. In other words, it is safe to use the index as a unique, persistent id for its frame.Additionally, the root node (null) is always at index 0.We use the indices into the "frames" array to avoid repeating the description of duplicate stack frames both when listing allocations, and when many stacks share the same tail of older frames. There shouldn't be any duplicates in the "frames" array, as that would defeat the purpose of this compression trick.In the future, we might want to split out a frame's "source" and "functionDisplayName" properties out the same way we have split frames out with the "frames" array. While this would further compress the size of the response packet, it would increase CPU usage to build the packet, and it should, of course, be guided by profiling and done only when necessary.

forceGarbageCollection

Force a browser-wide GC.

Returns Promise.Object allocation settings

forceCycleCollection

Force an XPCOM cycle collection. For more information on XPCOM cycle collection, see https://developer.mozilla.org/en-US/docs/Interfacing_with_the_XPCOM_cycle_collector#What_the_cycle_collector_does

Returns Promise.Object request response

measure

A method that returns a detailed breakdown of the memory consumption of the associated window.

Returns Object memory consumption

saveHeapSnapshot

Save a heap snapshot scoped to the current debuggees' portion of the heap graph.

Parameters

Returns String The snapshot id.