Closed Bug 701210 Opened 9 years ago Closed 9 years ago

nsTArray::SizeOf() should use malloc_usable_size

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla11
Tracking Status
firefox11 --- fixed

People

(Reporter: justin.lebar+bug, Assigned: justin.lebar+bug)

References

Details

(Whiteboard: [MemShrink][qa-])

Attachments

(1 file)

// @return The amount of memory taken used by this nsTArray, not including
  // sizeof(this)
  size_t SizeOf() const {
    return this->UsesAutoArrayBuffer() ?
      0 : this->Capacity() * sizeof(elem_type) + sizeof(*this->Hdr());
  }

This isn't as bad as it looks, because the capacity is chosen so that the capacity plus the header is a power of 2.  But there can be a few bytes of slop in there, and a call to Compact() will mess this calculation up.
Assignee: nobody → justin.lebar+bug
Blocks: 698326
Attached patch Patch v1Splinter Review
Attachment #573367 - Flags: review?(roc)
https://hg.mozilla.org/mozilla-central/rev/71ca2fa34ca9
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla11
Whiteboard: [MemShrink]
OOC, does this show up as a +1/-1 in the weekly MemShrink report?
(In reply to Justin Lebar [:jlebar] from comment #4)
> OOC, does this show up as a +1/-1 in the weekly MemShrink report?

No.  I record the open P1/P2/P3/U bug numbers each week, and diff with the previous week.  A bug that's fixed in this timeframe won't be present in either snapshot, so it won't be counted.
Whiteboard: [MemShrink] → [MemShrink][qa-]
You need to log in before you can comment on or make changes to this bug.