• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Leaking CGColor objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Leaking CGColor objects (From: DKJ <email@hidden>)

  • Prev by Date: Re: Leaking CGColor objects
  • Next by Date: Re: Leaking CGColor objects
  • Previous by thread: Re: Leaking CGColor objects
  • Next by thread: Re: Leaking CGColor objects
  • Index(es):
    • Date
    • Thread