Chasing Zombies in XCode 4

How to enable your XCode project with Zombie tracing — a quickie


            

Ok, this will be a short one. Probably I will create a category like “code snippets and hints” to include all these small articles. This is about zombies in your coding projects and how to chase them.

Enabling a project to trace zombies is different in XCode 4 than in previous versions. There is a special section inside “Run for debug” scheme.

Chasing zombies via edit scheme

Edit scheme in project options.

You have at least three ways to access this. One is using the “edit scheme” option in the drop down. The second is to choose product -> scheme -> edit scheme from XCode menu.

Chasing zombies in XCode 4 - edit scheme from menu

Choosing edit scheme from menu.

The third is to access edit scheme panel by pressing Cmd + Shift + <. The fourth is to access run options by pressing Cmd + Opt + R. In all cases, a dialog will open:

Run panel with enable zombie objects option under memory management section.

Run panel with enable zombie objects option under memory management section.

Check “Enable Zombie Objects” under “Memory Management” section and click Done. Test it by sending a message to a deallocated instance. Add, for example, this code in the awakeFromNib method:

    aString = [[NSString alloc] initWithFormat:@"Test"];
    [aString release];
    NSLog(@"%@", aString);

When the app starts, the following will appear on the console (and the app will crash):

A zombie: message to a deallocated instance — captured at runtime.

A zombie: message to a deallocated instance — captured at runtime.

Use it wisely. 😉

Plans for 2013

Another year started. Been so busy in the past month that I was unable to articulate some thoughts on my plans for 2013. This helps bringing some structured approach and — having a tendency to do many things at a time — should provide some prioritization. First, I would deepen my knowledge. In programming, in electronics and […]

How to use XCode 4 Exception Breakpoints

I will probably write a longer article on exception handling in XCode, for now just a quickie: how to use XCode 4 exception breakpoints, use the breakpoint customization features and get useful information for debugging. Usually when the app is crashing, a lot of cryptical mumbo-jumbo is displayed in the console. You have to dig the […]

Leave a Reply

Your email address will not be published. Required fields are marked *