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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 336273003: base: Add soft memory limit to DiscardableMemoryManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mac build Created 6 years, 5 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 | « base/memory/discardable_memory_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index c7ea9c71e78c6fcd3727d6326465f816285e075e..b8e2372c79cc8b6098f800bea8bfd9955b6c4c5b 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -953,6 +953,9 @@ void RenderThreadImpl::IdleHandler() {
if (!v8::V8::IdleNotification()) {
continue_timer = true;
}
+ if (!base::DiscardableMemory::ReduceMemoryUsage()) {
+ continue_timer = true;
+ }
// Schedule next invocation.
// Dampen the delay using the algorithm (if delay is in seconds):
@@ -994,10 +997,17 @@ void RenderThreadImpl::IdleHandlerInForegroundTab() {
int idle_hint = static_cast<int>(new_delay_ms / 10);
if (cpu_usage < kIdleCPUUsageThresholdInPercents) {
base::allocator::ReleaseFreeMemory();
- if (v8::V8::IdleNotification(idle_hint)) {
- // V8 finished collecting garbage.
+
+ bool finished_idle_work = true;
+ if (!v8::V8::IdleNotification(idle_hint))
+ finished_idle_work = false;
+ if (!base::DiscardableMemory::ReduceMemoryUsage())
+ finished_idle_work = false;
+
+ // V8 finished collecting garbage and discardable memory system has no
+ // more idle work left.
+ if (finished_idle_work)
new_delay_ms = kLongIdleHandlerDelayMs;
- }
}
}
ScheduleIdleHandler(new_delay_ms);
« no previous file with comments | « base/memory/discardable_memory_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698