summaryrefslogtreecommitdiffstats
path: root/cc/resources/resource_pool.cc
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-16 09:18:20 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-16 09:18:20 +0000
commitd55b31413b88c112ad2fc27dc3d96b238093148f (patch)
tree7cd65ca19a8a98bedcccdb263932aa0c4024c936 /cc/resources/resource_pool.cc
parentd491b7344458aeab36d76a8f5207e9a4182d1344 (diff)
downloadchromium_src-d55b31413b88c112ad2fc27dc3d96b238093148f.zip
chromium_src-d55b31413b88c112ad2fc27dc3d96b238093148f.tar.gz
chromium_src-d55b31413b88c112ad2fc27dc3d96b238093148f.tar.bz2
cc: Use LRU resource eviction pattern in ResourcePool.
Prevents resources that hard to reuse from being kept around and is less likely to cause spikes in memory usage on the driver side. BUG=254015 Review URL: https://chromiumcodereview.appspot.com/23070005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217981 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/resources/resource_pool.cc')
-rw-r--r--cc/resources/resource_pool.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc
index 06bc1fb..2d455a0 100644
--- a/cc/resources/resource_pool.cc
+++ b/cc/resources/resource_pool.cc
@@ -104,10 +104,15 @@ void ResourcePool::ReduceResourceUsage() {
if (!ResourceUsageTooHigh())
break;
- // MRU eviction pattern as least recently used is less likely to
- // be blocked by read lock fence.
- Resource* resource = unused_resources_.back();
- unused_resources_.pop_back();
+ // LRU eviction pattern. Most recently used might be blocked by
+ // a read lock fence but it's still better to evict the least
+ // recently used as it prevents a resource that is hard to reuse
+ // because of unique size from being kept around. Resources that
+ // can't be locked for write might also not be truly free-able.
+ // We can free the resource here but it doesn't mean that the
+ // memory is necessarily returned to the OS.
+ Resource* resource = unused_resources_.front();
+ unused_resources_.pop_front();
memory_usage_bytes_ -= resource->bytes();
unused_memory_usage_bytes_ -= resource->bytes();
--resource_count_;