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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 448173002: Re-land: base: Introduce an explicit call for reducing emulated discardable memory usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable EmulatedDiscardableMemoryDiscardedWhenWidgetsHidden with lsan Created 6 years, 4 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') | content/renderer/render_thread_impl_browsertest.cc » ('j') | 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 37fa09009169697a343cce73cfb9779f66e49937..daff6bc8dad3e7622981b6244ebe279ee38a3540 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -15,6 +15,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/discardable_memory.h"
+#include "base/memory/discardable_memory_emulated.h"
#include "base/memory/shared_memory.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
@@ -179,6 +180,9 @@ const int kMaxRasterThreads = 64;
// allocation that exceeds this limit.
const size_t kImageCacheSingleAllocationByteLimit = 64 * 1024 * 1024;
+const size_t kEmulatedDiscardableMemoryBytesToKeepWhenWidgetsHidden =
+ 4 * 1024 * 1024;
+
// Keep the global RenderThreadImpl in a TLS slot so it is impossible to access
// incorrectly from the wrong thread.
base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> >
@@ -545,10 +549,6 @@ void RenderThreadImpl::Init() {
base::DiscardableMemory::SetPreferredType(type);
- // Allow discardable memory implementations to register memory pressure
- // listeners.
- base::DiscardableMemory::RegisterMemoryPressureListeners();
-
// AllocateGpuMemoryBuffer must be used exclusively on one thread but
// it doesn't have to be the same thread RenderThreadImpl is created on.
allocate_gpu_memory_buffer_thread_checker_.DetachFromThread();
@@ -1623,6 +1623,12 @@ void RenderThreadImpl::WidgetHidden() {
hidden_widget_count_++;
if (widget_count_ && hidden_widget_count_ == widget_count_) {
+ // TODO(reveman): Remove this when we have a better mechanism to prevent
+ // total discardable memory used by all renderers from growing too large.
+ base::internal::DiscardableMemoryEmulated::
+ ReduceMemoryUsageUntilWithinLimit(
+ kEmulatedDiscardableMemoryBytesToKeepWhenWidgetsHidden);
+
if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden())
ScheduleIdleHandler(kInitialIdleHandlerDelayMs);
}
« no previous file with comments | « base/memory/discardable_memory_win.cc ('k') | content/renderer/render_thread_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698