NEVER test for memory leaks using -retainCount. ALWAYS use the supplied tools 
instead.

On 19 Jun 2011, at 15:29, Tony Cate wrote:

> - (NSImage *)illustration
> {
>    if ( illustrationData != nil ){
>        NSImage* thisImage = [NSImage new];
You never (auto)release this image, so it's getting leaked

>        NSBitmapImageRep* bitmapImageRep = [[NSBitmapImageRep alloc] 
> initWithData:illustrationData];
>        NSPICTImageRep* pictImageRep = [[NSPICTImageRep alloc] 
> initWithData:illustrationData];
> 
>        if ( bitmapImageRep != nil ){
>            [thisImage addRepresentation:bitmapImageRep];
>            [bitmapImageRep release];
>        }
>        if ( pictImageRep != nil ){
>            [thisImage addRepresentation:pictImageRep];
>            [pictImageRep release];
>        }
You are correctly managing memory for the image reps. The image itself is your 
problem.

>        return thisImage;
>    }
>    return nil;
> }
> 
> The logs look like this:
> 
> 2011-06-19 09:42:49.817 MyTestApp[92772:903] thisBitmapImageRep retainCount: 2
> 2011-06-19 09:42:49.820 MyTestApp[92772:903] thisBitmapImageRep retainCount: 3
> 2011-06-19 09:42:49.822 MyTestApp[92772:903] thisBitmapImageRep retainCount: 2
> 
> bitmapImageRep is leaking. Why is the retain count 2 after the initWithData:? 
> Should I file a bug?
> 
> Tony
> 
> 
> 
> _______________________________________________
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
> 
> This email sent to cocoa...@mikeabdullah.net

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to