diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-07 03:45:14 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-07 03:45:14 +0000 |
commit | 61e978ad63e1963c41db50e7b9b40580391a6170 (patch) | |
tree | 470f80302d66a831d7476c6a2022d39e6813e3c5 /skia | |
parent | c3e68d707ba949bba46594a91a2d30fdd18985e1 (diff) | |
download | chromium_src-61e978ad63e1963c41db50e7b9b40580391a6170.zip chromium_src-61e978ad63e1963c41db50e7b9b40580391a6170.tar.gz chromium_src-61e978ad63e1963c41db50e7b9b40580391a6170.tar.bz2 |
Fix memory leak of "screen size bitmap" (e.g. 1.5M if 750x548)
that happened on *every page view* on OSX.
VSIZE/RSIZE now hovers around 500M/30M instead of growing to 1.3G/260M
within a few minutes.
Surprisingly, Chromium.app seems quite a bit snappier!
The essence of the change is that SkBitmap::setPixels() does NOT take
ownership of the pointer, whereas SkBitmap::allocPixels() both
allocates and owns.
Review URL: http://codereview.chromium.org/39307
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11196 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rwxr-xr-x | skia/ext/bitmap_platform_device_mac.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/skia/ext/bitmap_platform_device_mac.cc b/skia/ext/bitmap_platform_device_mac.cc index a0f0bf1..a3f5e74 100755 --- a/skia/ext/bitmap_platform_device_mac.cc +++ b/skia/ext/bitmap_platform_device_mac.cc @@ -146,12 +146,11 @@ BitmapPlatformDeviceMac* BitmapPlatformDeviceMac::Create(CGContextRef context, int width, int height, bool is_opaque) { - void* data = malloc(height * width * 4); - if (!data) return NULL; - SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); - bitmap.setPixels(data); + if (bitmap.allocPixels() != true) + return NULL; + void* data = bitmap.getPixels(); // Note: The Windows implementation clears the Bitmap later on. // This bears mentioning since removal of this line makes the @@ -224,7 +223,7 @@ CGContextRef BitmapPlatformDeviceMac::GetBitmapContext() { return data_->GetBitmapContext(); } -void BitmapPlatformDeviceMac::setMatrixClip(const SkMatrix& transform, +void BitmapPlatformDeviceMac::setMatrixClip(const SkMatrix& transform, const SkRegion& region) { data_->SetMatrixClip(transform, region); } |