summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/resources/prioritized_resource_manager.cc10
-rw-r--r--content/common/gpu/gpu_memory_manager.cc23
-rw-r--r--content/common/gpu/gpu_memory_manager.h3
3 files changed, 23 insertions, 13 deletions
diff --git a/cc/resources/prioritized_resource_manager.cc b/cc/resources/prioritized_resource_manager.cc
index 43d4f52..da8f055 100644
--- a/cc/resources/prioritized_resource_manager.cc
+++ b/cc/resources/prioritized_resource_manager.cc
@@ -326,10 +326,14 @@ void PrioritizedResourceManager::ReduceWastedMemory(
continue;
wasted_memory += (*it)->bytes();
}
- size_t ten_percent_of_memory = memory_available_bytes_ / 10;
- if (wasted_memory > ten_percent_of_memory)
+ size_t wasted_memory_to_allow = memory_available_bytes_ / 10;
+ // If the external priority cutoff indicates that unused memory should be
+ // freed, then do not allow any memory for texture recycling.
+ if (external_priority_cutoff_ != PriorityCalculator::AllowEverythingCutoff())
+ wasted_memory_to_allow = 0;
+ if (wasted_memory > wasted_memory_to_allow)
EvictBackingsToReduceMemory(MemoryUseBytes() -
- (wasted_memory - ten_percent_of_memory),
+ (wasted_memory - wasted_memory_to_allow),
PriorityCalculator::AllowEverythingCutoff(),
EVICT_ONLY_RECYCLABLE,
DO_NOT_UNLINK_BACKINGS,
diff --git a/content/common/gpu/gpu_memory_manager.cc b/content/common/gpu/gpu_memory_manager.cc
index e693627..5dfd3fb 100644
--- a/content/common/gpu/gpu_memory_manager.cc
+++ b/content/common/gpu/gpu_memory_manager.cc
@@ -54,6 +54,7 @@ GpuMemoryManager::GpuMemoryManager(
manage_immediate_scheduled_(false),
max_surfaces_with_frontbuffer_soft_limit_(
max_surfaces_with_frontbuffer_soft_limit),
+ priority_cutoff_(MemoryAllocation::CUTOFF_ALLOW_EVERYTHING),
bytes_available_gpu_memory_(0),
bytes_available_gpu_memory_overridden_(false),
bytes_minimum_per_client_(0),
@@ -68,12 +69,23 @@ GpuMemoryManager::GpuMemoryManager(
{
CommandLine* command_line = CommandLine::ForCurrentProcess();
+ // Use a more conservative memory allocation policy on Linux and Mac because
+ // the platform is unstable when under memory pressure.
+ // http://crbug.com/145600 (Linux)
+ // http://crbug.com/141377 (Mac)
+#if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
+ priority_cutoff_ = MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE;
+#endif
+
#if defined(OS_ANDROID)
bytes_default_per_client_ = 8 * 1024 * 1024;
bytes_minimum_per_client_ = 8 * 1024 * 1024;
#elif defined(OS_CHROMEOS)
bytes_default_per_client_ = 64 * 1024 * 1024;
bytes_minimum_per_client_ = 4 * 1024 * 1024;
+#elif defined(OS_MACOSX)
+ bytes_default_per_client_ = 128 * 1024 * 1024;
+ bytes_minimum_per_client_ = 128 * 1024 * 1024;
#else
bytes_default_per_client_ = 64 * 1024 * 1024;
bytes_minimum_per_client_ = 64 * 1024 * 1024;
@@ -659,16 +671,7 @@ void GpuMemoryManager::AssignSurfacesAllocations() {
allocation.bytes_limit_when_visible =
client_state->bytes_allocation_when_visible_;
- // Use a more conservative memory allocation policy on Linux and Mac
- // because the platform is unstable when under memory pressure.
- // http://crbug.com/145600 (Linux)
- // http://crbug.com/141377 (Mac)
- allocation.priority_cutoff_when_visible =
-#if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
- MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE;
-#else
- MemoryAllocation::CUTOFF_ALLOW_EVERYTHING;
-#endif
+ allocation.priority_cutoff_when_visible = priority_cutoff_;
client_state->client_->SetMemoryAllocation(allocation);
client_state->client_->SuggestHaveFrontBuffer(!client_state->hibernated_);
diff --git a/content/common/gpu/gpu_memory_manager.h b/content/common/gpu/gpu_memory_manager.h
index a895968..255c20b 100644
--- a/content/common/gpu/gpu_memory_manager.h
+++ b/content/common/gpu/gpu_memory_manager.h
@@ -227,6 +227,9 @@ class CONTENT_EXPORT GpuMemoryManager :
uint64 max_surfaces_with_frontbuffer_soft_limit_;
+ // The priority cutoff used for all renderers.
+ gpu::MemoryAllocation::PriorityCutoff priority_cutoff_;
+
// The maximum amount of memory that may be allocated for GPU resources
uint64 bytes_available_gpu_memory_;
bool bytes_available_gpu_memory_overridden_;