Closed Bug 1486623 Opened 2 years ago Closed 2 years ago

DOM tree memory reporting likely misses some nodes

Categories

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

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: bzbarsky, Assigned: emilio)

References

Details

Attachments

(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:

  https://searchfox.org/mozilla-central/rev/55da592d85c2baf8d8818010c41d9738c97013d2/dom/xbl/nsXBLBinding.cpp#615

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 emilio@crisal.io:
https://hg.mozilla.org/integration/autoland/rev/2f49db02e5f6
Skip less nodes when reporting memory, and report ShadowRoot's StyleSheets. r=bzbarsky
https://hg.mozilla.org/mozilla-central/rev/2f49db02e5f6
Status: NEW → RESOLVED
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.