Question

What's a smart method to track class properties history in Xcode ?

I have a zombie property, and I don't understand when it is over released.

Also, I don't want to introduce memory leaks by erroneously over retaining it in the wrong place.

Thanks

Was it helpful?

Solution

I'm not sure what you exactly mean by tracking the history but on overreleasing objects there is an excellent tool called Instruments that can be used in conjunction with the NSZombieEnabled flag. The latter enables tracking that catches access to already-released objects (e.g. when overreleasing you access the release selector one more time on an already released object).

To do this in XCode 4 you select your app, select it to run in the simulator and Choose (in the Menu) Run -> Profile. Now Instruments should launch and present a selection of profiling options. You now select Zombies, the app starts and as soon as you hit a zombie object, a little flag will pop up in the timeline. There (clicking the arrow) you can access the offending object, the object's history (i.e. who retained and released that object) and if you enable the right sidebar, you also get a stacktrace for every entry.

Instruments running Zombie instrument

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top