Closed Bug 1486623 Opened 2 years ago Closed 2 years ago

DOM tree memory reporting likely misses some nodes


(Core :: DOM: Core & HTML, enhancement)

Not set



Tracking Status
firefox63 --- fixed


(Reporter: bzbarsky, Assigned: emilio)




(1 file)

There are two places we do memory reporting on DOM trees: nsDocument::DocAddSizeOfExcludingThis and xpc::OrphanReporter

The former uses AllChildrenIterator so it will miss nodes not in the flat tree, as well as ShadowRoots.

The latter does just a firstChild/nextSibling walk, so misses all the Shadow DOM stuff.

We should think about a way to make these walks actually hit all nodes.
Flags: needinfo?(emilio)
Blocks: 1486728
Assignee: nobody → emilio
Flags: needinfo?(emilio)
This moves all the node-specific reporting to nsIDocument.

OrphanReporter delegates all the reporting to that and then returns the sum of
all sizes, which is not ideal but was pre-existing.

Also, I moved the main mStyleSheets size reporting to DocumentOrShadowRoot for
it to be shared between document and ShadowRoot.

I'll add memory reporting for the computed stylesheet maps and such in the
ShadowRoot in a followup.

I went through all the XBL bindings, though it seems I could just use
GetBindingWithContent(), since according to:

We don't allow multiple bindings to contribute anon content. Anyway it was the
same amount of code...
Comment on attachment 9004512 [details]
Skip less nodes when reporting memory, and report ShadowRoot's StyleSheets.

Boris Zbarsky [:bzbarsky, bz on IRC] has approved the revision.
Attachment #9004512 - Flags: review+
Blocks: 1487198
Pushed by
Skip less nodes when reporting memory, and report ShadowRoot's StyleSheets. r=bzbarsky
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.