Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(694)

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 23888003: Free memory when the last WebView instance is destroyed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/AwContents.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 18ba0cca75fc4727e16cdad3210af97f00d3ef2c..25c17012fa32e0fb044b3ae58133cfb951bbf8a6 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -4,6 +4,7 @@
package org.chromium.android_webview;
+import android.content.ComponentCallbacks2;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Bitmap;
@@ -38,6 +39,7 @@ import com.google.common.annotations.VisibleForTesting;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
+import org.chromium.base.MemoryPressureListener;
import org.chromium.base.ThreadUtils;
import org.chromium.content.browser.ContentSettings;
import org.chromium.content.browser.ContentVideoView;
@@ -194,6 +196,13 @@ public class AwContents {
// This is a no-op if not currently attached.
nativeOnDetachedFromWindow(mNativeAwContents);
nativeDestroy(mNativeAwContents);
+
+ // Send a memory pressure signal for freeing up some memory if this
+ // is the last WebView instance.
+ if (getNativeInstanceCount() == 0) {
+ MemoryPressureListener.simulateMemoryPressureSignal(
+ ComponentCallbacks2.TRIM_MEMORY_COMPLETE);
joth 2013/09/03 18:37:58 It's always a bit hairy adding new code to the Cle
Primiano Tucci (use gerrit) 2013/09/05 11:47:25 Done.
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698