From 46036e9207983ef71d3cdb3ca06fefb1201a211f Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Mon, 22 Oct 2012 15:40:19 -0400 Subject: [PATCH] Bug 800166 - Fire a low-memory notification when a B2G process is backgrounded. r=gwagner,bent --- dom/ipc/ProcessPriorityManager.cpp | 7 +++++++ xpcom/base/nsIMemoryReporter.idl | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dom/ipc/ProcessPriorityManager.cpp b/dom/ipc/ProcessPriorityManager.cpp index ea258633f968..a0b42062ac6b 100644 --- a/dom/ipc/ProcessPriorityManager.cpp +++ b/dom/ipc/ProcessPriorityManager.cpp @@ -298,6 +298,13 @@ ProcessPriorityManager::OnGracePeriodTimerFired() mGracePeriodTimer = nullptr; hal::SetProcessPriority(getpid(), PROCESS_PRIORITY_BACKGROUND); + + // We're in the background; dump as much memory as we can. + nsCOMPtr mgr = + do_GetService("@mozilla.org/memory-reporter-manager;1"); + if (mgr) { + mgr->MinimizeMemoryUsage(/* callback = */ nullptr); + } } } // anonymous namespace diff --git a/xpcom/base/nsIMemoryReporter.idl b/xpcom/base/nsIMemoryReporter.idl index f6e6ddc98f53..259a9d81b1a2 100644 --- a/xpcom/base/nsIMemoryReporter.idl +++ b/xpcom/base/nsIMemoryReporter.idl @@ -295,7 +295,8 @@ interface nsIMemoryReporterManager : nsISupports /* * Run a series of GC/CC's in an attempt to minimize the application's memory - * usage. When we're finished, we invoke the given runnable. + * usage. When we're finished, we invoke the given runnable if it's not + * null. */ void minimizeMemoryUsage(in nsIRunnable callback); };