My day was ruined by this message:
*** -[CALayer retainCount]: message sent to deallocated instance 0x656b260
Since I don't create CALayer myself in this case, it can only be the CALayer of a UIView which might be anything from a UIButton to a UISlider.
So I got a great answer from Jeff to my question about how to trace this down in Xcode 4.
Jeff recommended hitting Command + I to launch the Profiler and then select the Zombies instrument. Indeed, the Zombies instrument stopped on that CALayer and threw a more useful stack trace at me.
However, the Stack Trace isn't that useful as it does not tell me which object that Zombie really was. Every UIView has a CALayer, but the point is I don't create these CALayer instances myself. So in this case the goal is to know to which UIView (button, slider, whatever) that CALayer belongs to.
0 libSystem.B.dylib calloc
1 libobjc.A.dylib class_createInstanceXcode4
2 CoreFoundation +[NSObject(NSObject) allocWithZone:]
3 CoreFoundation +[NSObject(NSObject) alloc]
4 UIKit -[UIView _createLayerWithFrame:]
5 UIKit UIViewCommonInitWithFrame
6 UIKit -[UIView initWithFrame:]
7 UIKit -[UIControl initWithFrame:]
8 UIKit -[UIButton initWithFrame:]
9 UIKit +[UIButton buttonWithType:]
10 TestApp +[CCButton buttonWithNormalImage:pressedImageName:] /Users/tom/Documents/testcomp/Projects/TestApp/Xcode4/Classes/CCButton.m:267
11 TestApp -[ConfigView setupCommitBlade] /Users/tom/Documents/testcomp/Projects/TestApp/Xcode4/Classes/ConfigView.m:606
12 TestApp -[ConfigView initWithRootVC:] /Users/tom/Documents/testcomp/Projects/TestApp/Xcode4/Classes/ConfigView.m:714
13 TestApp -[TestAppViewController loadConfigViewIfNeeded] /Users/tom/Documents/testcomp/Projects/TestApp/Xcode4/Classes/TestAppViewController.m:69
14 TestApp -[TestAppViewController viewDidLoad] /Users/tom/Documents/testcomp/Projects/TestApp/Xcode4/Classes/TestAppViewController.m:293
15 UIKit -[UIViewController view]
16 TestApp -[TestAppAppDelegate application:didFinishLaunchingWithOptions:] /Users/tom/Documents/testcomp/Projects/TestApp/Xcode4/Classes/TestAppAppDelegate.m:238
17 UIKit -[UIApplication _callInitializationDelegatesForURL:payload:suspended:]
18 UIKit -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:]
19 UIKit -[UIApplication handleEvent:withNewEvent:]
20 UIKit -[UIApplication sendEvent:]
21 UIKit _UIApplicationHandleEvent
22 GraphicsServices PurpleEventCallback
23 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
24 CoreFoundation __CFRunLoopDoSource1
25 CoreFoundation __CFRunLoopRun
26 CoreFoundation CFRunLoopRunSpecific
27 CoreFoundation CFRunLoopRunInMode
28 UIKit -[UIApplication _run]
29 UIKit UIApplicationMain
30 TestApp main /Users/tom/Documents/testcomp/Projects/TestApp/Xcode4/main.m:14
31 TestApp start
Maybe someone can point out a tutorial or video which shows how to profile a problem like this in Xcode4? As far as I remember, Xcode 3 really pointed out which object it was, but here I just don't see where the evil is. There must be some rule of thumb how to interpret this stack trace correctly / or a good reason why the Zombies instrument doesn't simply point out the line of code where the zombie appeared.