Commit 4885b8e3 authored by primiano@chromium.org's avatar primiano@chromium.org

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
parent 006899ce
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment