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

Unified Diff: chrome/renderer/render_thread.cc

Issue 206017: Issue 172109: Enable scavenging in RenderThread::IdleHandler.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | « chrome/renderer/DEPS ('k') | third_party/tcmalloc/config_linux.h » ('j') | 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 26229)
+++ chrome/renderer/render_thread.cc (working copy)
@@ -48,6 +48,7 @@
#include "webkit/extensions/v8/gears_extension.h"
#include "webkit/extensions/v8/interval_extension.h"
#include "webkit/extensions/v8/playback_extension.h"
+#include "third_party/tcmalloc/google/malloc_extension.h"
#if defined(OS_WIN)
#include <windows.h>
@@ -459,26 +460,29 @@
if (!widget_count_ || hidden_widget_count_ < widget_count_)
return;
- if (v8::V8::IsDead())
- return;
+#if defined(OS_WIN)
+ MallocExtension::instance()->Scavenge();
+#endif
- LOG(INFO) << "RenderThread calling v8 IdleNotification for " << this;
+ if (!v8::V8::IsDead()) {
+ LOG(INFO) << "RenderThread calling v8 IdleNotification for " << this;
+ v8::V8::IdleNotification(false);
+ }
- // When V8::IdleNotification returns true, it means that it has cleaned up
- // as much as it can. There is no point in continuing to call it.
- if (!v8::V8::IdleNotification(false)) {
- // Dampen the delay using the algorithm:
- // delay = delay + 1 / (delay + 2)
- // Using floor(delay) has a dampening effect such as:
- // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ...
- idle_notification_delay_in_s_ +=
- 1.0 / (idle_notification_delay_in_s_ + 2.0);
+ // Schedule next invocation.
+ // Dampen the delay using the algorithm:
+ // delay = delay + 1 / (delay + 2)
+ // Using floor(delay) has a dampening effect such as:
+ // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ...
+ // Note that idle_notification_delay_in_s_ would be reset to
+ // kInitialIdleHandlerDelayS in RenderThread::WidgetHidden.
+ idle_notification_delay_in_s_ +=
+ 1.0 / (idle_notification_delay_in_s_ + 2.0);
- // Schedule the next timer.
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- task_factory_->NewRunnableMethod(&RenderThread::IdleHandler),
- static_cast<int64>(floor(idle_notification_delay_in_s_)) * 1000);
- }
+ // Schedule the next timer.
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ task_factory_->NewRunnableMethod(&RenderThread::IdleHandler),
+ static_cast<int64>(floor(idle_notification_delay_in_s_)) * 1000);
}
void RenderThread::OnExtensionMessageInvoke(const std::string& function_name,
« no previous file with comments | « chrome/renderer/DEPS ('k') | third_party/tcmalloc/config_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698