Bug 1472495: Don't report shared memmapped cache as explicit memory. r?erahm
MozReview-Commit-ID: 7xWJOdg3mfg
--- a/js/xpconnect/loader/ScriptPreloader.cpp
+++ b/js/xpconnect/loader/ScriptPreloader.cpp
@@ -84,20 +84,32 @@ ScriptPreloader::CollectReports(nsIHandl
"Memory used to hold the scripts which have been restored from the "
"startup script cache file, but have not been executed in this session.");
MOZ_COLLECT_REPORT(
"explicit/script-preloader/heap/other", KIND_HEAP, UNITS_BYTES,
ShallowHeapSizeOfIncludingThis(MallocSizeOf),
"Memory used by the script cache service itself.");
- MOZ_COLLECT_REPORT(
- "explicit/script-preloader/non-heap/memmapped-cache", KIND_NONHEAP, UNITS_BYTES,
- mCacheData.nonHeapSizeOfExcludingThis(),
- "The memory-mapped startup script cache file.");
+ // Since the mem-mapped cache file is mapped into memory, we want to report
+ // it as explicit memory somewhere. But since the child cache is shared
+ // between all processes, we don't want to report it as explicit memory for
+ // all of them. So we report it as explicit only in the parent process, and
+ // non-explicit everywhere else.
+ if (XRE_IsParentProcess()) {
+ MOZ_COLLECT_REPORT(
+ "explicit/script-preloader/non-heap/memmapped-cache", KIND_NONHEAP, UNITS_BYTES,
+ mCacheData.nonHeapSizeOfExcludingThis(),
+ "The memory-mapped startup script cache file.");
+ } else {
+ MOZ_COLLECT_REPORT(
+ "script-preloader-memmapped-cache", KIND_NONHEAP, UNITS_BYTES,
+ mCacheData.nonHeapSizeOfExcludingThis(),
+ "The memory-mapped startup script cache file.");
+ }
return NS_OK;
}
ScriptPreloader&
ScriptPreloader::GetSingleton()
{