Bug 699951 - add a memory reporter for heap usage by the disk cache. r=michal

This commit is contained in:
Nick Hurley
2012-11-05 10:22:33 -08:00
parent c1136d3534
commit 604807457f
13 changed files with 149 additions and 10 deletions

View File

@@ -181,12 +181,8 @@ nsDiskCacheMap::Open(nsIFile * cacheDirectory,
goto error_exit;
}
{
// extra scope so the compiler doesn't barf on the above gotos jumping
// past this declaration down here
uint32_t overhead = moz_malloc_size_of(mRecordArray);
Telemetry::Accumulate(Telemetry::HTTP_DISK_CACHE_OVERHEAD, overhead);
}
Telemetry::Accumulate(Telemetry::HTTP_DISK_CACHE_OVERHEAD,
(uint32_t)SizeOfExcludingThis(moz_malloc_size_of));
*corruptInfo = nsDiskCache::kNotCorrupt;
return NS_OK;
@@ -1217,6 +1213,24 @@ nsDiskCacheMap::NotifyCapacityChange(uint32_t capacity)
}
}
size_t
nsDiskCacheMap::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf)
{
size_t usage = aMallocSizeOf(mRecordArray);
usage += aMallocSizeOf(mBuffer);
usage += aMallocSizeOf(mMapFD);
usage += aMallocSizeOf(mCleanFD);
usage += aMallocSizeOf(mCacheDirectory);
usage += aMallocSizeOf(mCleanCacheTimer);
for (int i = 0; i < kNumBlockFiles; i++) {
usage += mBlockFile[i].SizeOfExcludingThis(aMallocSizeOf);
}
return usage;
}
nsresult
nsDiskCacheMap::InitCacheClean(nsIFile * cacheDirectory,
nsDiskCache::CorruptCacheInfo * corruptInfo,