nsTArray::SizeOf() should use malloc_usable_size

RESOLVED FIXED in Firefox 11

Status

()

Core
XPCOM
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Justin Lebar (not reading bugmail), Assigned: Justin Lebar (not reading bugmail))

Tracking

unspecified
mozilla11
Points:
---

Firefox Tracking Flags

(firefox11 fixed)

Details

(Whiteboard: [MemShrink][qa-])

Attachments

(1 attachment)

(Assignee)

Description

6 years ago
// @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)

Updated

6 years ago
Assignee: nobody → justin.lebar+bug
(Assignee)

Updated

6 years ago
Blocks: 698326
(Assignee)

Comment 1

6 years ago
Created attachment 573367 [details] [diff] [review]
Patch v1
Attachment #573367 - Flags: review?(roc)
Attachment #573367 - Flags: review?(roc) → review+
(Assignee)

Comment 2

6 years ago
Thanks, roc.

https://hg.mozilla.org/integration/mozilla-inbound/rev/71ca2fa34ca9
status-firefox11: --- → fixed
https://hg.mozilla.org/mozilla-central/rev/71ca2fa34ca9
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla11
Whiteboard: [MemShrink]
(Assignee)

Comment 4

6 years ago
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.