diff options
author | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-15 16:08:54 +0000 |
---|---|---|
committer | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-15 16:08:54 +0000 |
commit | 653f0422c015947678043d7240d5bf9c9aad74e0 (patch) | |
tree | b2f75af6cb9e0f263209088ec994f92645cbd1da /cc/resources/resource_pool.cc | |
parent | 353bb1f78ccbac8969df0a260268ff86df1b9784 (diff) | |
download | chromium_src-653f0422c015947678043d7240d5bf9c9aad74e0.zip chromium_src-653f0422c015947678043d7240d5bf9c9aad74e0.tar.gz chromium_src-653f0422c015947678043d7240d5bf9c9aad74e0.tar.bz2 |
cc: Fix ResourcePool busy resource leak
Currently busy resources in ResourcePool are not deleted on ResourcePool
destruction. This is ok on most platfroms (except android webview)
because ResourcePool life time is tied to ResourceProvider, which will
clean up this leak. On android webview however, ResourcePool is deleted
in LayerTreeHostImpl::ReleaseGL and ResourceProvider is destroyed later
on cc tear down.
Add DCHECKs in ResourcePool destructor to catch this in the future.
This change requires making sure that tests that use tile resources
always have a ResourceProvider and all tile resources created in tests
are accounted for by the ResourcePool.
BUG=
NOTRY=true
Review URL: https://codereview.chromium.org/70143004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235339 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/resources/resource_pool.cc')
-rw-r--r-- | cc/resources/resource_pool.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc index 6e367af..5281023 100644 --- a/cc/resources/resource_pool.cc +++ b/cc/resources/resource_pool.cc @@ -39,7 +39,16 @@ ResourcePool::ResourcePool(ResourceProvider* resource_provider) } ResourcePool::~ResourcePool() { + while (!busy_resources_.empty()) { + DidFinishUsingResource(busy_resources_.front()); + busy_resources_.pop_front(); + } + SetResourceUsageLimits(0, 0, 0); + DCHECK_EQ(0u, unused_resources_.size()); + DCHECK_EQ(0u, memory_usage_bytes_); + DCHECK_EQ(0u, unused_memory_usage_bytes_); + DCHECK_EQ(0u, resource_count_); } scoped_ptr<ResourcePool::Resource> ResourcePool::AcquireResource( @@ -126,8 +135,7 @@ void ResourcePool::CheckBusyResources() { Resource* resource = *it; if (resource_provider_->CanLockForWrite(resource->id())) { - unused_memory_usage_bytes_ += resource->bytes(); - unused_resources_.push_back(resource); + DidFinishUsingResource(resource); it = busy_resources_.erase(it); } else { ++it; @@ -135,4 +143,9 @@ void ResourcePool::CheckBusyResources() { } } +void ResourcePool::DidFinishUsingResource(ResourcePool::Resource* resource) { + unused_memory_usage_bytes_ += resource->bytes(); + unused_resources_.push_back(resource); +} + } // namespace cc |