Bug 1451005 - Add low commit-space event counts to the memory reporter; r?njn
MozReview-Commit-ID: 1jZwxj427tg
--- a/toolkit/components/aboutmemory/tests/test_memoryReporters.xul
+++ b/toolkit/components/aboutmemory/tests/test_memoryReporters.xul
@@ -152,16 +152,17 @@
"heapOverheadFraction",
"JSMainRuntimeGCHeap",
"JSMainRuntimeTemporaryPeak",
"JSMainRuntimeCompartmentsSystem",
"JSMainRuntimeCompartmentsUser",
"imagesContentUsedUncompressed",
"storageSQLite",
"lowMemoryEventsVirtual",
+ "lowMemoryEventsCommitSpace",
"lowMemoryEventsPhysical",
"ghostWindows",
"pageFaultsHard",
];
for (let i = 0; i < amounts.length; i++) {
try {
// If mgr[amounts[i]] throws an exception, just move on -- some amounts
// aren't available on all platforms. But if the attribute simply
--- a/xpcom/base/AvailableMemoryTracker.cpp
+++ b/xpcom/base/AvailableMemoryTracker.cpp
@@ -447,16 +447,22 @@ nsAvailableMemoryWatcher::Observe(nsISup
static int64_t
LowMemoryEventsVirtualDistinguishedAmount()
{
return sNumLowVirtualMemEvents;
}
static int64_t
+LowMemoryEventsCommitSpaceDistinguishedAmount()
+{
+ return sNumLowCommitSpaceEvents;
+}
+
+static int64_t
LowMemoryEventsPhysicalDistinguishedAmount()
{
return sNumLowPhysicalMemEvents;
}
class LowEventsReporter final : public nsIMemoryReporter
{
~LowEventsReporter() {}
@@ -473,17 +479,17 @@ public:
"Number of low-virtual-memory events fired since startup. We fire such an "
"event if we notice there is less than memory.low_virtual_mem_threshold_mb of "
"virtual address space available (if zero, this behavior is disabled). The "
"process will probably crash if it runs out of virtual address space, so "
"this event is dire.");
MOZ_COLLECT_REPORT(
"low-memory-events/commit-space", KIND_OTHER, UNITS_COUNT_CUMULATIVE,
- sNumLowCommitSpaceEvents,
+ LowMemoryEventsCommitSpaceDistinguishedAmount(),
"Number of low-commit-space events fired since startup. We fire such an "
"event if we notice there is less than memory.low_commit_space_threshold_mb of "
"commit space available (if zero, this behavior is disabled). Windows will "
"likely kill the process if it runs out of commit space, so this event is "
"dire.");
MOZ_COLLECT_REPORT(
"low-memory-events/physical", KIND_OTHER, UNITS_COUNT_CUMULATIVE,
--- a/xpcom/base/nsIMemoryReporter.idl
+++ b/xpcom/base/nsIMemoryReporter.idl
@@ -365,19 +365,19 @@ interface nsIMemoryReporterManager : nsI
* |JSMainRuntimeCompartments{System,User}| (UNITS_COUNT) The number of
* {system,user} compartments in the main JS runtime.
*
* |imagesContentUsedUncompressed| (UNITS_BYTES) Memory used for decoded
* raster images in content.
*
* |storageSQLite| (UNITS_BYTES) Memory used by SQLite.
*
- * |lowMemoryEvents{Virtual,Physical}| (UNITS_COUNT_CUMULATIVE) The number
- * of low-{virtual,physical}-memory events that have occurred since the
- * process started.
+ * |lowMemoryEvents{Virtual,CommitSpace,Physical}| (UNITS_COUNT_CUMULATIVE)
+ * The number of low-{virtual,commit-space,physical}-memory events that have
+ * occurred since the process started.
*
* |ghostWindows| (UNITS_COUNT) A cached value of the number of ghost
* windows. This should have been updated within the past 60s.
*
* |pageFaultsHard| (UNITS_COUNT_CUMULATIVE) The number of hard (a.k.a.
* major) page faults that have occurred since the process started.
*/
[must_use] readonly attribute int64_t vsize;
@@ -395,16 +395,17 @@ interface nsIMemoryReporterManager : nsI
[must_use] readonly attribute int64_t JSMainRuntimeCompartmentsSystem;
[must_use] readonly attribute int64_t JSMainRuntimeCompartmentsUser;
[must_use] readonly attribute int64_t imagesContentUsedUncompressed;
[must_use] readonly attribute int64_t storageSQLite;
[must_use] readonly attribute int64_t lowMemoryEventsVirtual;
+ [must_use] readonly attribute int64_t lowMemoryEventsCommitSpace;
[must_use] readonly attribute int64_t lowMemoryEventsPhysical;
[must_use] readonly attribute int64_t ghostWindows;
[must_use] readonly attribute int64_t pageFaultsHard;
/*
* This attribute indicates if moz_malloc_usable_size() works.
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -2515,16 +2515,22 @@ nsMemoryReporterManager::GetStorageSQLit
NS_IMETHODIMP
nsMemoryReporterManager::GetLowMemoryEventsVirtual(int64_t* aAmount)
{
return GetInfallibleAmount(mAmountFns.mLowMemoryEventsVirtual, aAmount);
}
NS_IMETHODIMP
+nsMemoryReporterManager::GetLowMemoryEventsCommitSpace(int64_t* aAmount)
+{
+ return GetInfallibleAmount(mAmountFns.mLowMemoryEventsCommitSpace, aAmount);
+}
+
+NS_IMETHODIMP
nsMemoryReporterManager::GetLowMemoryEventsPhysical(int64_t* aAmount)
{
return GetInfallibleAmount(mAmountFns.mLowMemoryEventsPhysical, aAmount);
}
NS_IMETHODIMP
nsMemoryReporterManager::GetGhostWindows(int64_t* aAmount)
{
--- a/xpcom/base/nsMemoryReporterManager.h
+++ b/xpcom/base/nsMemoryReporterManager.h
@@ -144,16 +144,17 @@ public:
mozilla::InfallibleAmountFn mJSMainRuntimeCompartmentsSystem;
mozilla::InfallibleAmountFn mJSMainRuntimeCompartmentsUser;
mozilla::InfallibleAmountFn mImagesContentUsedUncompressed;
mozilla::InfallibleAmountFn mStorageSQLite;
mozilla::InfallibleAmountFn mLowMemoryEventsVirtual;
+ mozilla::InfallibleAmountFn mLowMemoryEventsCommitSpace;
mozilla::InfallibleAmountFn mLowMemoryEventsPhysical;
mozilla::InfallibleAmountFn mGhostWindows;
AmountFns()
{
mozilla::PodZero(this);
}