diff options
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/DEPS | 1 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 40 |
2 files changed, 23 insertions, 18 deletions
diff --git a/chrome/renderer/DEPS b/chrome/renderer/DEPS index 4012ed4..f8b66fe 100644 --- a/chrome/renderer/DEPS +++ b/chrome/renderer/DEPS @@ -13,6 +13,7 @@ include_rules = [ "+webkit/glue/plugins", "+v8/include", "+third_party/sqlite/preprocessed", + "+third_party/tcmalloc", # FIXME - refactor code and remove these dependencies "+chrome/browser/net", diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index fd076ba..e7c04ed 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -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 @@ void RenderThread::IdleHandler() { if (!widget_count_ || hidden_widget_count_ < widget_count_) return; - if (v8::V8::IsDead()) - return; - - LOG(INFO) << "RenderThread calling v8 IdleNotification for " << this; - - // 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); +#if defined(OS_WIN) + MallocExtension::instance()->Scavenge(); +#endif - // Schedule the next timer. - MessageLoop::current()->PostDelayedTask(FROM_HERE, - task_factory_->NewRunnableMethod(&RenderThread::IdleHandler), - static_cast<int64>(floor(idle_notification_delay_in_s_)) * 1000); + if (!v8::V8::IsDead()) { + LOG(INFO) << "RenderThread calling v8 IdleNotification for " << this; + v8::V8::IdleNotification(false); } + + // 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); } void RenderThread::OnExtensionMessageInvoke(const std::string& function_name, |