Bug 1046477 (part 2) - Don't measure the heap size of static atoms. r=froydnj.
This commit is contained in:
@@ -106,7 +106,7 @@ public:
|
|||||||
// for |#ifdef NS_BUILD_REFCNT_LOGGING| access to reference count
|
// for |#ifdef NS_BUILD_REFCNT_LOGGING| access to reference count
|
||||||
nsrefcnt GetRefCount() { return mRefCnt; }
|
nsrefcnt GetRefCount() { return mRefCnt; }
|
||||||
|
|
||||||
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -470,12 +470,20 @@ AtomImpl::IsStaticAtom()
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
AtomImpl::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
AtomImpl::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf)
|
||||||
{
|
{
|
||||||
return aMallocSizeOf(this) +
|
size_t n = aMallocSizeOf(this);
|
||||||
nsStringBuffer::FromData(mString)->SizeOfIncludingThisIfUnshared(
|
|
||||||
|
// Don't measure static atoms. Nb: here "static" means "permanent", and while
|
||||||
|
// it's not guaranteed that permanent atoms are actually stored in static
|
||||||
|
// data, it is very likely. And we don't want to call |aMallocSizeOf| on
|
||||||
|
// static data, so we err on the side of caution.
|
||||||
|
if (!IsStaticAtom()) {
|
||||||
|
n += nsStringBuffer::FromData(mString)->SizeOfIncludingThisIfUnshared(
|
||||||
aMallocSizeOf);
|
aMallocSizeOf);
|
||||||
}
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -488,15 +496,6 @@ SizeOfAtomTableEntryExcludingThis(PLDHashEntryHdr* aHdr,
|
|||||||
return entry->mAtom->SizeOfIncludingThis(aMallocSizeOf);
|
return entry->mAtom->SizeOfIncludingThis(aMallocSizeOf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
|
||||||
SizeOfStaticAtomTableEntryExcludingThis(const nsAString& aKey,
|
|
||||||
nsIAtom* const& aData,
|
|
||||||
MallocSizeOf aMallocSizeOf,
|
|
||||||
void* aArg)
|
|
||||||
{
|
|
||||||
return aKey.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NS_SizeOfAtomTablesIncludingThis(MallocSizeOf aMallocSizeOf,
|
NS_SizeOfAtomTablesIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||||
size_t* aMain, size_t* aStatic)
|
size_t* aMain, size_t* aStatic)
|
||||||
@@ -507,9 +506,10 @@ NS_SizeOfAtomTablesIncludingThis(MallocSizeOf aMallocSizeOf,
|
|||||||
aMallocSizeOf)
|
aMallocSizeOf)
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
|
// The atoms in the this table are almost certainly stored in static data, so
|
||||||
|
// we don't need a SizeOfEntry function.
|
||||||
*aStatic = gStaticAtomTable
|
*aStatic = gStaticAtomTable
|
||||||
? gStaticAtomTable->SizeOfIncludingThis(SizeOfStaticAtomTableEntryExcludingThis,
|
? gStaticAtomTable->SizeOfIncludingThis(nullptr, aMallocSizeOf)
|
||||||
aMallocSizeOf)
|
|
||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user