nsTArray::SizeOf() should use malloc_usable_size

RESOLVED FIXED in Firefox 11

Status

()

defect
RESOLVED FIXED
8 years ago
8 years ago

People

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

Tracking

unspecified
mozilla11
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox11 fixed)

Details

(Whiteboard: [MemShrink][qa-])

Attachments

(1 attachment)

// @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
Posted patch Patch v1Splinter Review
Attachment #573367 - Flags: review?(roc)
https://hg.mozilla.org/mozilla-central/rev/71ca2fa34ca9
Status: NEW → RESOLVED
Closed: 8 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.