diff --git a/toolkit/components/aboutmemory/tests/test_aboutmemory.xul b/toolkit/components/aboutmemory/tests/test_aboutmemory.xul index d00e1ae1538b..8c5a9945dafd 100644 --- a/toolkit/components/aboutmemory/tests/test_aboutmemory.xul +++ b/toolkit/components/aboutmemory/tests/test_aboutmemory.xul @@ -119,21 +119,6 @@ mgr.registerStrongReporterEvenIfBlocked(fakeReporters[i]); } - // mgr.explicit sums "heap-allocated" and all the appropriate NONHEAP ones: - // - "explicit/c", "explicit/cc" x 2, "explicit/d", "explicit/e" - // - but *not* "explicit/c/d" x 2 - // Check explicit now before we add the fake reporters for the fake 2nd - // and subsequent processes. - // - // Nb: mgr.explicit will throw NS_ERROR_NOT_AVAILABLE if this is a - // --disable-jemalloc build. Allow for that exception, but *only* that - // exception. - try { - is(mgr.explicit, 500*MB + (100 + 13 + 10)*MB + 599*KB, "mgr.explicit"); - } catch (ex) { - is(ex.result, Cr.NS_ERROR_NOT_AVAILABLE, "mgr.explicit exception"); - } - // The main process always comes first when we display about:memory. The // remaining processes are sorted by their |resident| values (starting with // the largest). Processes without a |resident| memory reporter are saved diff --git a/toolkit/components/aboutmemory/tests/test_memoryReporters.xul b/toolkit/components/aboutmemory/tests/test_memoryReporters.xul index d9f1b81064e3..5a96c3bd4cac 100644 --- a/toolkit/components/aboutmemory/tests/test_memoryReporters.xul +++ b/toolkit/components/aboutmemory/tests/test_memoryReporters.xul @@ -141,21 +141,6 @@ let mgr = Cc["@mozilla.org/memory-reporter-manager;1"]. getService(Ci.nsIMemoryReporterManager); - // Access the distinguished amounts (mgr.explicit et al.) just to make sure - // they don't crash. We can't check their actual values because they're - // non-deterministic. - // - // Nb: mgr.explicit will throw NS_ERROR_NOT_AVAILABLE if this is a - // --disable-jemalloc build. Allow for that exception, but *only* that - // exception. - let dummy; - let haveExplicit = true; - try { - dummy = mgr.explicit; - } catch (ex) { - is(ex.result, Cr.NS_ERROR_NOT_AVAILABLE, "mgr.explicit exception"); - haveExplicit = false; - } let amounts = [ "vsize", "vsizeMaxContiguous", @@ -182,7 +167,7 @@ // aren't available on all platforms. But if the attribute simply // isn't present, that indicates the distinguished amounts have changed // and this file hasn't been updated appropriately. - dummy = mgr[amounts[i]]; + let dummy = mgr[amounts[i]]; ok(dummy !== undefined, "accessed an unknown distinguished amount: " + amounts[i]); } catch (ex) { @@ -226,9 +211,14 @@ } } - // If mgr.explicit failed, we won't have "heap-allocated" either. - if (haveExplicit) { + try { + // Nb: mgr.heapAllocated will throw NS_ERROR_NOT_AVAILABLE if this is a + // --disable-jemalloc build. Allow for skipping this test on that + // exception, but *only* that exception. + let dummy = mgr.heapAllocated; checkSpecialReport("heap-allocated", heapAllocatedAmounts); + } catch (ex) { + is(ex.result, Cr.NS_ERROR_NOT_AVAILABLE, "mgr.heapAllocated exception"); } // vsize may be unreasonable if ASAN is enabled checkSpecialReport("vsize", vsizeAmounts, /*canBeUnreasonable*/true); diff --git a/xpcom/base/nsIMemoryReporter.idl b/xpcom/base/nsIMemoryReporter.idl index 5ff894112593..82d26c03b122 100644 --- a/xpcom/base/nsIMemoryReporter.idl +++ b/xpcom/base/nsIMemoryReporter.idl @@ -205,7 +205,7 @@ interface nsIFinishReportingCallback : nsISupports void callback(in nsISupports data); }; -[scriptable, builtinclass, uuid(5e4eaa5a-4808-4b97-8005-e7cdc4d73693)] +[scriptable, builtinclass, uuid(fcad440e-64dd-4fb8-9a5e-b19d1b91423b)] interface nsIMemoryReporterManager : nsISupports { /* @@ -325,11 +325,6 @@ interface nsIMemoryReporterManager : nsISupports * If you add a new distinguished amount, please update * toolkit/components/aboutmemory/tests/test_memoryReporters.xul. * - * |explicit| (UNITS_BYTES) The total size of explicit memory allocations, - * both at the OS-level (eg. via mmap, VirtualAlloc) and at the heap level - * (eg. via malloc, calloc, operator new). It covers all heap allocations, - * but will miss any OS-level ones not covered by memory reporters. - * * |vsize| (UNITS_BYTES) The virtual size, i.e. the amount of address space * taken up. * @@ -378,7 +373,6 @@ interface nsIMemoryReporterManager : nsISupports * |pageFaultsHard| (UNITS_COUNT_CUMULATIVE) The number of hard (a.k.a. * major) page faults that have occurred since the process started. */ - readonly attribute int64_t explicit; readonly attribute int64_t vsize; readonly attribute int64_t vsizeMaxContiguous; readonly attribute int64_t resident; diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 69db11fc37c4..cc506a1b5ff7 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -1944,84 +1944,6 @@ nsMemoryReporterManager::UnblockRegistrationAndRestoreOriginalReporters() return NS_OK; } -// This is just a wrapper for int64_t that implements nsISupports, so it can be -// passed to nsIMemoryReporter::CollectReports. -class Int64Wrapper final : public nsISupports -{ - ~Int64Wrapper() {} - -public: - NS_DECL_ISUPPORTS - Int64Wrapper() : mValue(0) - { - } - int64_t mValue; -}; - -NS_IMPL_ISUPPORTS0(Int64Wrapper) - -class ExplicitCallback final : public nsIHandleReportCallback -{ - ~ExplicitCallback() {} - -public: - NS_DECL_ISUPPORTS - - NS_IMETHOD Callback(const nsACString& aProcess, const nsACString& aPath, - int32_t aKind, int32_t aUnits, int64_t aAmount, - const nsACString& aDescription, - nsISupports* aWrappedExplicit) override - { - // Using the "heap-allocated" reporter here instead of - // nsMemoryReporterManager.heapAllocated goes against the usual - // pattern. But it's for a good reason: in tests, we can easily - // create artificial (i.e. deterministic) reporters -- which allows us - // to precisely test nsMemoryReporterManager.explicit -- but we can't - // do that for distinguished amounts. - if (aPath.EqualsLiteral("heap-allocated") || - (aKind == nsIMemoryReporter::KIND_NONHEAP && - PromiseFlatCString(aPath).Find("explicit") == 0)) { - Int64Wrapper* wrappedInt64 = static_cast(aWrappedExplicit); - wrappedInt64->mValue += aAmount; - } - return NS_OK; - } -}; - -NS_IMPL_ISUPPORTS(ExplicitCallback, nsIHandleReportCallback) - -NS_IMETHODIMP -nsMemoryReporterManager::GetExplicit(int64_t* aAmount) -{ - if (NS_WARN_IF(!aAmount)) { - return NS_ERROR_INVALID_ARG; - } - *aAmount = 0; -#ifndef HAVE_JEMALLOC_STATS - return NS_ERROR_NOT_AVAILABLE; -#else - - // For each reporter we call CollectReports and filter out the - // non-explicit, non-NONHEAP measurements (except for "heap-allocated"). - // That's lots of wasted work, and we used to have a GetExplicitNonHeap() - // method which did this more efficiently, but it ended up being more - // trouble than it was worth. - - nsRefPtr handleReport = new ExplicitCallback(); - nsRefPtr wrappedExplicitSize = new Int64Wrapper(); - - // Anonymization doesn't matter here, because we're only summing all the - // reported values. Enable it anyway because it's slightly faster, since it - // doesn't have to get URLs, find notable strings, etc. - GetReportsForThisProcess(handleReport, wrappedExplicitSize, - /* anonymize = */ true); - - *aAmount = wrappedExplicitSize->mValue; - - return NS_OK; -#endif // HAVE_JEMALLOC_STATS -} - NS_IMETHODIMP nsMemoryReporterManager::GetVsize(int64_t* aVsize) {