I'm having (in my opinion) a very difficult problem in my code. It crashes randomly at different places in the code. The project is a ARC project.
So my program crashes occaisonally with this messages:
malloc: *** error for object 0xd2dd8b0: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
I already set a breakpoint for malloc_error_break
but I don't get any information out of it. When the code crashes ,XCode shows me the place in the code where it happens. But as I already said the crashes are randomly and do not occur always. But it seems as if the crashes are concentrated at on particular line in the code.
Now, I wanted to debug it using the instruments that come with xcode. After a bit of googling i found the following stuff on stackoverflow: How do I set up NSZombieEnabled in Xcode 4? and Xcode malloc error.
So the first link describes how to start zombie detection out of xcode itself by clicking the run button in xcode and choose "Profile". The problem I have is, that I cannot find "Zombies" when choosing the template for the trace document in my version of xcode (4.2). But if I start Instruments outside xcode (e.g. from finder) I can choose zombies.
Okay, here is what I did:
1) Start Instruments from finder and choose Profile "Zombies".
2) Start iphone app from xcode in the iphone simulator (normal run (not profile or debug)).
3) In Instruments "Choose Target"->"Attach to process"->"iPhone Simulator (57529)".
4) Instruments begins to recod something (I cannot figure out what it does).
5) Start playing around with the app until it crashes.
Eventually the app crashes and here is a screenshot of instruments after crashing the app:
My questions:
1) Is Zombies adequate for my problem or should I use another analyizes tool?
2) What tells me instruments in it's output after crashing?
Judging by your description of the problem, your crash is caused by something besides accessing a zombie object. If your app accesses a deallocated (zombie) object, Instruments shows a message like the following when using the Zombies template: