• 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: "Julien Jalon" <email@hidden>
  • Date: Sun, 26 Oct 2008 16:46:02 +0100

On Sun, Oct 26, 2008 at 4:20 PM, Antonio Nunes <email@hidden>wrote:

> On 26 Oct 2008, at 14:25, DKJ wrote:
>
>  1. Is there such a thing as a CGColor class? I don't see it in the
>> documentation; but "CGColor" is what Instruments lists as the leaked
>> objects.
>>
>
> You are creating CGColor objects to which you receive pointers of type
> CGColorRef. You are at C level here, not Objective-C.
>
>  2. Are the CGColor objects being leaked when I remove MyCALayer objects
>> from myArray? Should I set foregroundColor to nil when doing this?
>>
>
> You need to make sure in the MyCALayer dealloc method to release the color
> you created during init using something like
> CGColorRelease(self.foregroundColor).
>

Bad idea: you don't know for sure self.foregroundColor instance will be the
one created in the first place (the one that is leaking). The flaw is at the
beginning:

        self.foregroundColor =
               CGColorCreateGenericRGB( 1.0, 1.0, 0.9, 1.0 );

should be

       CGColorRef color = CGColorCreateGenericRGB( 1.0, 1.0, 0.9, 1.0 );
       self.foregroundColor = color;
       CFRelease(color);

--
Julien
_______________________________________________

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: 
 >Leaking CGColor objects (From: DKJ <email@hidden>)
 >Re: Leaking CGColor objects (From: Antonio Nunes <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