зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1536154 - Make nsStringInputStream always report the full memory size of the backing string r=baku
Give nsIStringStream separate SizeOfIncludingThisIfUnshared and SizeOfIncludingThisEvenIfShared methods. Use the former for memory reporting and the latter for JS engine memory accounting. Differential Revision: https://phabricator.services.mozilla.com/D29336
This commit is contained in:
Родитель
51a0721c6a
Коммит
0eb4059201
|
@ -146,7 +146,7 @@ StreamBlobImpl::CollectReports(nsIHandleReportCallback* aHandleReport,
|
|||
|
||||
MOZ_COLLECT_REPORT(
|
||||
"explicit/dom/memory-file-data/stream", KIND_HEAP, UNITS_BYTES,
|
||||
stringInputStream->SizeOfIncludingThis(MallocSizeOf),
|
||||
stringInputStream->SizeOfIncludingThisIfUnshared(MallocSizeOf),
|
||||
"Memory used to back a File/Blob based on an input stream.");
|
||||
|
||||
return NS_OK;
|
||||
|
@ -159,7 +159,7 @@ size_t StreamBlobImpl::GetAllocationSize() const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
return stringInputStream->SizeOfIncludingThis(MallocSizeOf);
|
||||
return stringInputStream->SizeOfIncludingThisEvenIfShared(MallocSizeOf);
|
||||
}
|
||||
|
||||
void StreamBlobImpl::GetBlobImplType(nsAString& aBlobImplType) const {
|
||||
|
|
|
@ -62,5 +62,8 @@ interface nsIStringInputStream : nsIInputStream
|
|||
[noscript] void shareData(in string data, in long dataLen);
|
||||
|
||||
[noscript, notxpcom]
|
||||
size_t SizeOfIncludingThis(in MallocSizeOf aMallocSizeOf);
|
||||
size_t SizeOfIncludingThisIfUnshared(in MallocSizeOf aMallocSizeOf);
|
||||
|
||||
[noscript, notxpcom]
|
||||
size_t SizeOfIncludingThisEvenIfShared(in MallocSizeOf aMallocSizeOf);
|
||||
};
|
||||
|
|
|
@ -196,7 +196,7 @@ nsStringInputStream::ShareData(const char* aData, int32_t aDataLen) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP_(size_t)
|
||||
nsStringInputStream::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) {
|
||||
nsStringInputStream::SizeOfIncludingThisIfUnshared(MallocSizeOf aMallocSizeOf) {
|
||||
ReentrantMonitorAutoEnter lock(mMon);
|
||||
|
||||
size_t n = aMallocSizeOf(this);
|
||||
|
@ -204,6 +204,16 @@ nsStringInputStream::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) {
|
|||
return n;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(size_t)
|
||||
nsStringInputStream::SizeOfIncludingThisEvenIfShared(
|
||||
MallocSizeOf aMallocSizeOf) {
|
||||
ReentrantMonitorAutoEnter lock(mMon);
|
||||
|
||||
size_t n = aMallocSizeOf(this);
|
||||
n += mData.SizeOfExcludingThisEvenIfShared(aMallocSizeOf);
|
||||
return n;
|
||||
}
|
||||
|
||||
/////////
|
||||
// nsIInputStream implementation
|
||||
/////////
|
||||
|
|
Загрузка…
Ссылка в новой задаче