views:

142

answers:

1

Hi

As my programs involves more and more code Im starting to get a bit frustrated with the error messages that are thrown in the console:

2009-11-14 14:31:57.513 FC[915:5b27] *** -[SearchResultParser respondsToSelector:]: message sent to deallocated instance 0x82d28e0

This one is not the worst as it actually tells me that it has to do with a selector and that it originates in SearchResultParser. But often I just get "message sent to deallocated instance 0x897867d6".

Other times it is the stack dump, where it just tells me, what I think is, the memory allocations for objects currently in the stack.

Maybe Im spoiled, but I have been use to a lot more info from the error messages, especially from dynamic languages: like line number where the error occurred, instance names of the objects in question and so on.

I read up on using Instruments and there is of course break points. It can just feel a bit pointless manually going through 20+ deallocations and 300 lines of code to find out what caused a halt, when the answer is right in front of you:"0x82d28e0 caused the crash"!

In a bad way I reminds me of the error messages I got from my micro controller IDE:)

Is there a way to go from the instance address e.g. 0x82d28e0 to the instance name? Is there a way to use the information from the console to narrow down where in the code the halt is caused? Especially the "message sent to deallocated instance" since Im apparently a bit to eager with my memory management:)

Hope someone out there can help me get to understand the console better:) Thanks.

+4  A: 

The problem with this error is that at the moment the error occurs the deallocated instance is no longer available so the debugger has no information about it. This kind of error never happens in languages with automatic memory management so you can't really compare them in this regard.

Look at the NSZombieEnabled parameter. If you enable zombies, objects are converted to a zombie when your code wants to deallocate them. These can later give you more information about themselves when your code tries to release them once more.

Ole Begemann
+1 for recommending NSZombieEnabled - good recommendation
Till
Thank You Ole:)I went to check and I actually had NSZombieEnabled=YES. I think I read something about it some weeks ago and just set that value. Is there something more I need to do? I couldn't really find anything else that "NSZombies are awsome, set to YES" out there.Thanks again:)
RickiG