Re: Leaking CGColor objects
Re: Leaking CGColor objects
- Subject: Re: Leaking CGColor objects
- From: Charles Steinman <email@hidden>
- Date: Sun, 26 Oct 2008 12:32:09 -0700 (PDT)
--- On Sun, 10/26/08, DKJ <email@hidden> wrote:
> If I do this in MyCALayer's dealloc:
>
> self.foregroundColor = nil;
>
> do I need to do this in init:
>
> CGColorRef temp = CGColorCreateGenericRGB( etc. );
> self.foregroundColor = temp;
> CFRelease( temp );
>
> or can I just do this:
>
> self.foregroundColor = CGColorCreateGenericRGB( etc. );
>
> For the time being, I'll do both.
You need to do both. Consider CGColorCreateGenericRGB() as being equivalent to an [[NSObject alloc] init]. You need a release to balance it. This actually applies to all CFTypeRef-type objects -- they need to be released or they'll leak.
Cheers,
Chuck
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden