Closed Bug 1026985 Opened 11 years ago Closed 11 years ago

Stop reporting the memory use of nsAttrValue's MiscContainer objects if they are shared

Categories

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

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: jwatt, Assigned: jwatt)

References

Details

(Whiteboard: [MemShrink])

Attachments

(2 files)

I'm seeing a single twice-reported entry in a DMD report. In that entry the "Reported at" and "Reported again at" stacks are identical. From code inspection I can't see how that is possible.
Attached file twice reported section
This happened when I ran Firefox with the -layoutdebug command line argument, then loaded: http://www.w3schools.com/CSSref/tryit.asp?filename=trycss_gen_counter-reset before triggering DMD's report.
Consider the stack: WindowsMallocSizeOf nsAttrValue::SizeOfExcludingThis nsAttrAndChildArray::SizeOfExcludingThis mozilla::dom::FragmentOrElement::SizeOfExcludingThis nsINode::SizeOfIncludingThis nsDocument::DocAddSizeOfExcludingThis nsHTMLDocument::DocAddSizeOfExcludingThis We can be pretty sure that nsDocument::DocAddSizeOfExcludingThis is not being called twice since if it was we'd be getting much more than just the single twice-reported entry. nsDocument::DocAddSizeOfExcludingThis is clearly at this line when nsINode::SizeOfIncludingThis is called: https://mxr.mozilla.org/mozilla-central/source/content/base/src/nsDocument.cpp?rev=72961f73cb4a#11955 and that section of code can't be creating a duplicate report - if the nsINode was in the child list twice then the nsINode itself would also appear as twice-reported. nsINode::SizeOfIncludingThis also doesn't seem to be responsible since it just does |aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf)|. FragmentOrElement::SizeOfExcludingThis calls mAttrsAndChildren.SizeOfExcludingThis() only once, and nsAttrValue::SizeOfExcludingThis only calls aMallocSizeOf() once on the MiscContainer that is being double reported.
Any thoughts?
Flags: needinfo?(n.nethercote)
This is probably a bug in the memory reporter (not DMD) where a shared MiscContainer is actually being twice reported. A comment in |nsAttrValue::ClearMiscContainer| implies that MiscContainers can be shared [1]. I haven't completely traced through, but it looks like two nsAttrAndChildArrays are sharing a MiscContainer. [1] http://dxr.mozilla.org/mozilla-central/source/content/base/src/nsAttrValue.cpp#1768
You're right. I should have spotted that, thanks!
Summary: Something may be rotten in DMD's twice-reported entries → Stop reporting the memory use of nsAttrValue's MiscContainer objects if they are shared
Attached patch patchSplinter Review
Assignee: nobody → jwatt
Attachment #8442235 - Flags: review?(bzbarsky)
Flags: needinfo?(n.nethercote)
Component: DMD → DOM
Whiteboard: [MemShrink]
Thanks for spotting, erahm!
Attachment #8442235 - Flags: review?(bzbarsky) → review+
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: