summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-11 05:49:28 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-11 05:49:28 +0000
commit8cd3f3d465eeb69e92c1cd3ca4de0cad5515c75c (patch)
tree10dcf17162113400ad822cbbc470baaf4cfc16c6
parent8a06057d5fbea970aec4e5291cd80db3178409e5 (diff)
downloadchromium_src-8cd3f3d465eeb69e92c1cd3ca4de0cad5515c75c.zip
chromium_src-8cd3f3d465eeb69e92c1cd3ca4de0cad5515c75c.tar.gz
chromium_src-8cd3f3d465eeb69e92c1cd3ca4de0cad5515c75c.tar.bz2
Merge 221669 "Free memory when the last WebView instance is dest..."
> Free memory when the last WebView instance is destroyed. > > Sending a (TRIM_MEMORY_COMPLETE) memory pressure signal to free some > memory (v8,sqlite,image decoding caches) when the last WebView instance > is destroyed. > > BUG=284362 > NOTRY=true > > Review URL: https://chromiumcodereview.appspot.com/23888003 TBR=primiano@chromium.org Review URL: https://codereview.chromium.org/24103002 git-svn-id: svn://svn.chromium.org/chrome/branches/1599/src@222482 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--android_webview/native/aw_contents.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
index 714d9dd..fcda25b 100644
--- a/android_webview/native/aw_contents.cc
+++ b/android_webview/native/aw_contents.cc
@@ -27,6 +27,7 @@
#include "base/atomicops.h"
#include "base/bind.h"
#include "base/callback.h"
+#include "base/memory/memory_pressure_listener.h"
#include "base/message_loop/message_loop.h"
#include "base/pickle.h"
#include "base/strings/string16.h"
@@ -250,6 +251,14 @@ jint AwContents::GetWebContents(JNIEnv* env, jobject obj) {
void AwContents::Destroy(JNIEnv* env, jobject obj) {
delete this;
+
+ // When the last WebView is destroyed free all discardable memory allocated by
+ // Chromium, because the app process may continue to run for a long time
+ // without ever using another WebView.
+ if (base::subtle::NoBarrier_Load(&g_instance_count) == 0) {
+ base::MemoryPressureListener::NotifyMemoryPressure(
+ base::MemoryPressureListener::MEMORY_PRESSURE_CRITICAL);
+ }
}
static jint Init(JNIEnv* env, jclass, jobject browser_context) {