Bug 803154 - Don't wait on Gecko for non-emergency memory reduction events r=kats
authorJames Willcox <jwillcox@mozilla.com>
Tue, 29 Jan 2013 13:24:43 -0500
changeset 120252 b211a11259a7e4b622f57ca599a041cfed99149c
parent 120251 3a8a7a8502be210bd3748421c540512c6cb72765
child 120253 6f3581295ea798d0f73c303678a06acda218b02f
push id24243
push userryanvm@gmail.com
push dateWed, 30 Jan 2013 00:49:21 +0000
treeherdermozilla-central@5c248ef0fe62 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs803154
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 803154 - Don't wait on Gecko for non-emergency memory reduction events r=kats
mobile/android/base/MemoryMonitor.java
--- a/mobile/android/base/MemoryMonitor.java
+++ b/mobile/android/base/MemoryMonitor.java
@@ -148,17 +148,25 @@ class MemoryMonitor extends BroadcastRec
             return;
         }
 
         // TODO hook in memory-reduction stuff for different levels here
         if (level >= MEMORY_PRESSURE_MEDIUM) {
             if (GeckoThread.checkLaunchState(GeckoThread.LaunchState.GeckoRunning)) {
                 GeckoAppShell.onLowMemory();
             }
-            GeckoAppShell.geckoEventSync();
+
+            if (level >= MEMORY_PRESSURE_HIGH) {
+                // We need to wait on Gecko here, because this is normally called
+                // from Activity.onLowMemory. If we haven't reduced memory usage
+                // enough when we return from that, Android will kill us.
+                // Activity.onTrimMemory is more of a suggestion.
+                GeckoAppShell.geckoEventSync();
+            }
+
             Favicons.getInstance().clearMemCache();
         }
     }
 
     private boolean decreaseMemoryPressure() {
         int newLevel;
         synchronized (this) {
             if (mMemoryPressure <= 0) {