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

Unified Diff: cc/resources/tile_manager.cc

Issue 23231002: cc: Prevent the tile manager from allocating more memory than allowed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 | « cc/resources/resource_pool.cc ('k') | cc/resources/tile_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/tile_manager.cc
diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc
index 86de61041b2c7f0da7abb96474970e064a2b465f..cff5883078b9c86ed91783f0b66222ec8b381c7f 100644
--- a/cc/resources/tile_manager.cc
+++ b/cc/resources/tile_manager.cc
@@ -180,7 +180,7 @@ TileManager::~TileManager() {
void TileManager::SetGlobalState(
const GlobalStateThatImpactsTilePriority& global_state) {
global_state_ = global_state;
- resource_pool_->SetMemoryUsageLimits(
+ resource_pool_->SetResourceUsageLimits(
global_state_.memory_limit_in_bytes,
global_state_.unused_memory_limit_in_bytes,
global_state_.num_resources_limit);
@@ -499,9 +499,10 @@ void TileManager::AssignGpuMemoryToTiles(
static_cast<int64>(bytes_releasable_) +
static_cast<int64>(global_state_.memory_limit_in_bytes) -
static_cast<int64>(resource_pool_->acquired_memory_usage_bytes());
- int resources_available = resources_releasable_ +
- global_state_.num_resources_limit -
- resource_pool_->NumResources();
+ int resources_available =
+ resources_releasable_ +
+ global_state_.num_resources_limit -
+ resource_pool_->acquired_resource_count();
size_t bytes_allocatable =
std::max(static_cast<int64>(0), bytes_available);
@@ -705,6 +706,10 @@ void TileManager::ScheduleTasks(
tasks.Append(tile_version.raster_task_, tile->required_for_activation());
}
+ // We must reduce the amount of unused resoruces before calling
+ // ScheduleTasks to prevent usage from rising above limits.
+ resource_pool_->ReduceResourceUsage();
+
// Schedule running of |tasks|. This replaces any previously
// scheduled tasks and effectively cancels all tasks not present
// in |tasks|.
« no previous file with comments | « cc/resources/resource_pool.cc ('k') | cc/resources/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698