diff options
author | primiano@chromium.org <primiano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-06 10:12:41 +0000 |
---|---|---|
committer | primiano@chromium.org <primiano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-06 10:12:41 +0000 |
commit | 4885b8e334a52a77212c8c66fd885532836697cd (patch) | |
tree | 0fd51629bbe96f8e0d709461f6cae742dd034408 /android_webview | |
parent | 006899ce9ca80799593d6c8f056cae9c00c5d71d (diff) | |
download | chromium_src-4885b8e334a52a77212c8c66fd885532836697cd.zip chromium_src-4885b8e334a52a77212c8c66fd885532836697cd.tar.gz chromium_src-4885b8e334a52a77212c8c66fd885532836697cd.tar.bz2 |
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
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221669 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
-rw-r--r-- | android_webview/native/aw_contents.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index 82100be..a00c1fe 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) { |