Last Comment Bug 701210 - nsTArray::SizeOf() should use malloc_usable_size
: nsTArray::SizeOf() should use malloc_usable_size
Product: Core
Classification: Components
Component: XPCOM (show other bugs)
: unspecified
: All All
: -- normal (vote)
: mozilla11
Assigned To: Justin Lebar (not reading bugmail)
: Nathan Froyd [:froydnj]
Depends on:
Blocks: 698326
  Show dependency treegraph
Reported: 2011-11-09 15:17 PST by Justin Lebar (not reading bugmail)
Modified: 2012-02-01 13:17 PST (History)
5 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Patch v1 (1.92 KB, patch)
2011-11-09 16:32 PST, Justin Lebar (not reading bugmail)
roc: review+
Details | Diff | Splinter Review

Description Justin Lebar (not reading bugmail) 2011-11-09 15:17:58 PST
// @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.
Comment 1 Justin Lebar (not reading bugmail) 2011-11-09 16:32:00 PST
Created attachment 573367 [details] [diff] [review]
Patch v1
Comment 2 Justin Lebar (not reading bugmail) 2011-11-09 17:41:51 PST
Thanks, roc.
Comment 3 Marco Bonardo [::mak] 2011-11-10 03:28:13 PST
Comment 4 Justin Lebar (not reading bugmail) 2011-11-10 12:07:19 PST
OOC, does this show up as a +1/-1 in the weekly MemShrink report?
Comment 5 Nicholas Nethercote [:njn] 2011-11-10 14:18:16 PST
(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.

Note You need to log in before you can comment on or make changes to this bug.