Commit 82ba6a40 authored by jbauman@chromium.org's avatar jbauman@chromium.org

Fix leak with SharedBitmaps allocated by new[]

The handle_map_ was holding onto them, so they weren't being released. Instead, they should be removed from the map whenever that first SharedBitmap that was created is destroyed.

BUG=362924
TBR=piman@chromium.org

Review URL: https://codereview.chromium.org/310973003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274765 0039d316-1c4b-4281-b951-d872f2087c98
parent 43d0610a
...@@ -63,7 +63,10 @@ scoped_ptr<cc::SharedBitmap> HostSharedBitmapManager::AllocateSharedBitmap( ...@@ -63,7 +63,10 @@ scoped_ptr<cc::SharedBitmap> HostSharedBitmapManager::AllocateSharedBitmap(
cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); cc::SharedBitmapId id = cc::SharedBitmap::GenerateId();
handle_map_[id] = data; handle_map_[id] = data;
return make_scoped_ptr(new cc::SharedBitmap( return make_scoped_ptr(new cc::SharedBitmap(
data->pixels.get(), id, base::Bind(&FreeSharedMemory, data))); data->pixels.get(),
id,
base::Bind(&HostSharedBitmapManager::FreeSharedMemoryFromMap,
base::Unretained(this))));
} }
scoped_ptr<cc::SharedBitmap> HostSharedBitmapManager::GetSharedBitmapFromId( scoped_ptr<cc::SharedBitmap> HostSharedBitmapManager::GetSharedBitmapFromId(
...@@ -184,4 +187,10 @@ void HostSharedBitmapManager::ProcessRemoved( ...@@ -184,4 +187,10 @@ void HostSharedBitmapManager::ProcessRemoved(
process_map_.erase(proc_it); process_map_.erase(proc_it);
} }
void HostSharedBitmapManager::FreeSharedMemoryFromMap(
cc::SharedBitmap* bitmap) {
base::AutoLock lock(lock_);
handle_map_.erase(bitmap->id());
}
} // namespace content } // namespace content
...@@ -68,6 +68,8 @@ class CONTENT_EXPORT HostSharedBitmapManager : public cc::SharedBitmapManager { ...@@ -68,6 +68,8 @@ class CONTENT_EXPORT HostSharedBitmapManager : public cc::SharedBitmapManager {
size_t AllocatedBitmapCount() const { return handle_map_.size(); } size_t AllocatedBitmapCount() const { return handle_map_.size(); }
private: private:
void FreeSharedMemoryFromMap(cc::SharedBitmap* bitmap);
base::Lock lock_; base::Lock lock_;
typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData> > typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData> >
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment