On Thu, 20 Oct 2011 17:38:03 -0400, Bill Cheeseman <wjcheese...@gmail.com> said:
>
>Specifically, if your Cocoa method returns a CFTypeRef object retained, and 
>you don't put "Copy" or "Create" in the method name, Analyze reports a 
>"potential" memory leak. Go back and insert "Copy" or "Create" into the method 
>name, and Analyze no longer reports a potential memory leak. To me, it makes 
>all the sense in the world to apply the "create rule" to Cocoa methods that 
>return Core Foundation CFTypeRef objects.

I just tried that it and it didn't help:

- (CGContextRef) bitmapContextCreate:(CGSize)size {
        int bitmapBytesPerRow = (size.width * 4);
        bitmapBytesPerRow += (16 - bitmapBytesPerRow%16)%16;
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
        CGContextRef context = NULL;
        context = CGBitmapContextCreate(NULL, size.width, size.height, 
            8, bitmapBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast);
        CGColorSpaceRelease(colorSpace);
        return context;
}

As long as I am returning a context obtained with CGBitmapContextCreate and not 
autoreleased, it doesn't matter what I name the method: the analyzer is 
unhappy. And under ARC it isn't clear what I can do about this, since I can't 
autorelease anything and I can't invite ARC to do so (and anyway I don't want 
to). Only adding CF_RETURNS_RETAINED quieted the analyzer. m.

--
matt neuburg, phd = m...@tidbits.com, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to