CALayer memory management [was: Tracking down CALayer problem in iTunes plug-in]
CALayer memory management [was: Tracking down CALayer problem in iTunes plug-in]
- Subject: CALayer memory management [was: Tracking down CALayer problem in iTunes plug-in]
- From: Graham Cox <email@hidden>
- Date: Mon, 01 Aug 2011 17:34:06 +1000
I've narrowed this error down to a very simple test case.
I have a CALayer subclass. In this subclass, I've added properties which are synthesized and retained (in fact, they are NSColors). I don't attempt to animate these properties.
In my -dealloc method, I'm setting these properties to nil, in accordance with normal procedure for a synthesized property, so that whatever I'm retaining gets released. When I do this, I always get this error logged to the console:
1/08/11 3:30:48 PM iTunes[38653] attempting to modify layer that is being finalized - 0x1a2a87f0
It's only logged once, but from then on the whole Core Animation system shuts down - I can no longer get any visual display from any layer. I'm guessing that this is a 'feature', in that an attempt to modify a layer is for some reason a highly dangerous operation during finalization (I'm writing this code as if it used retain/release, but it might be using GC, as it's a plug-in hosted by the (new, Cocoa) version of iTunes - I don't know whether it uses GC or not). If I neglect to clean up these properties, I don't get the error, the CA system continues to work, but of course I'm then leaking my colour objects.
What's the proper way to correctly clean up a CALayer subclass and make sure I'm not leaking retained properties NOR modifying the layer at finalize time?
--Graham
On 28/07/2011, at 1:07 PM, Graham Cox wrote:
> When I clean-up my visualizer view, I see this in the console:
>
> 28/07/11 12:43:40 AM iTunes[22132] attempting to modify layer that is being finalized - 0x1ec78650
_______________________________________________
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