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

Unified Diff: chrome/renderer/render_thread.cc

Issue 267021: Add functionality to the renderer thread to purge memory. Not yet called.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | « chrome/renderer/render_thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_thread.cc
===================================================================
--- chrome/renderer/render_thread.cc (revision 28361)
+++ chrome/renderer/render_thread.cc (working copy)
@@ -46,6 +46,9 @@
#include "ipc/ipc_message.h"
#include "webkit/api/public/WebCache.h"
#include "webkit/api/public/WebColor.h"
+#include "webkit/api/public/WebCrossOriginPreflightResultCache.h"
+#include "webkit/api/public/WebFontCache.h"
+#include "webkit/api/public/WebColor.h"
#include "webkit/api/public/WebKit.h"
#include "webkit/api/public/WebStorageEventDispatcher.h"
#include "webkit/api/public/WebString.h"
@@ -61,6 +64,8 @@
#endif
using WebKit::WebCache;
+using WebKit::WebCrossOriginPreflightResultCache;
+using WebKit::WebFontCache;
using WebKit::WebString;
using WebKit::WebStorageEventDispatcher;
@@ -287,6 +292,7 @@
OnExtensionMessageInvoke)
IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetFunctionNames,
OnSetExtensionFunctionNames)
+ IPC_MESSAGE_HANDLER(ViewMsg_PurgeMemory, OnPurgeMemory)
IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache,
OnPurgePluginListCache)
IPC_MESSAGE_HANDLER(ViewMsg_Extension_UpdatePageActions,
@@ -509,6 +515,32 @@
RendererExtensionBindings::Invoke(function_name, args, NULL);
}
+void RenderThread::OnPurgeMemory() {
+ EnsureWebKitInitialized();
+
+ // Clear the object cache (as much as possible; some live objects cannot be
+ // freed).
+ WebCache::clear();
+
+ // Clear the font/glyph cache.
+ WebFontCache::clear();
+
+ // Clear the Cross-Origin Preflight cache.
+ WebCrossOriginPreflightResultCache::clear();
+
+ // Repeatedly call the V8 idle notification until it returns true ("nothing
+ // more to free"). Note that it makes more sense to do this than to implement
+ // a new "delete everything" pass because object references make it difficult
+ // to free everything possible in just one pass.
+ while (!v8::V8::IdleNotification())
+ ;
+
+#if defined(OS_WIN)
+ // Tell tcmalloc to release any free pages it's still holding.
+ MallocExtension::instance()->ReleaseFreeMemory();
+#endif
+}
+
void RenderThread::OnPurgePluginListCache(bool reload_pages) {
EnsureWebKitInitialized();
// The call below will cause a GetPlugins call with refresh=true, but at this
« no previous file with comments | « chrome/renderer/render_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698