The default bug view has changed. See this FAQ.

Add nsTArray::SizeOf

RESOLVED FIXED in mozilla8

Status

()

Core
XPCOM
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: khuey, Assigned: khuey)

Tracking

Trunk
mozilla8
x86
Windows 7
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [MemShrink])

Attachments

(1 attachment)

Created attachment 548525 [details] [diff] [review]
Patch

For about:memory reporting usage.
Attachment #548525 - Flags: review?(benjamin)
Attachment #548525 - Flags: review?(benjamin) → review+
http://hg.mozilla.org/mozilla-central/rev/030c419226ed
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Target Milestone: --- → mozilla8
this has been backed out
http://hg.mozilla.org/mozilla-central/rev/9517e7652dec
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Whiteboard: [MemShrink]

Comment 3

6 years ago
Comment on attachment 548525 [details] [diff] [review]
Patch

>+  // @return The amount of memory taken used by this nsTArray, not including
>+  // sizeof(this)
>+  size_t SizeOf() const {
>+    return Capacity() * sizeof(elem_type) + sizeof(mHdr);
Except the mHdr is shared between non-auto nsTArrays...
(In reply to comment #3)
> Comment on attachment 548525 [details] [diff] [review] [diff] [details] [review]
> Patch
> 
> >+  // @return The amount of memory taken used by this nsTArray, not including
> >+  // sizeof(this)
> >+  size_t SizeOf() const {
> >+    return Capacity() * sizeof(elem_type) + sizeof(mHdr);
> Except the mHdr is shared between non-auto nsTArrays...

That's only true if the nsTArray is empty, no?
Comment on attachment 548525 [details] [diff] [review]
Patch

This bounced with

../../../dist/include/nsTArray.h: In member function 'size_t nsTArray<E, Alloc>::SizeOf() const':
../../../dist/include/nsTArray.h:436:21: error: there are no arguments to 'Capacity' that depend on a template parameter, so a declaration of 'Capacity' must be available
../../../dist/include/nsTArray.h:436:21: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
../../../dist/include/nsTArray.h:436:52: error: 'mHdr' was not declared in this scope

Not quite sure what to make of these ... it looks like base class members aren't in scope?
You need this->Capacity. Bare names are not in scope in template classes that inherit from other templated classes. C++ is weird like that.
Added the 'this' qualifiers.

http://hg.mozilla.org/mozilla-central/rev/bd93ca20e1fd
Assignee: nobody → khuey
Status: REOPENED → RESOLVED
Last Resolved: 6 years ago6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.