Question

I've got an issue with an object not being deallocated in objective-c. I'm pretty certain this is because it is being retained somewhere, but I don't know where (checking retainCount where it ought to be 0 returns a 1). I've gone through my code many times but fail to see what's retaining it that I don't release. Might even be a bug in the frameworks I'm using.

How would you deal with something like this? I thought maybe you could search through the memory and see what's pointing to this object, making it considerably easier to figure out why it is like this, but I'm not quite sure how to achieve that. Maybe another solution?

Was it helpful?

Solution

Have you tried Instruments?

OTHER TIPS

Instruments is great, and can pick up on leaked objects if and when they are leaked, but in cases like these I suggest you first use the Xcode Static Analyzer, new in Xcode 3.2 with Snow Leopard. (If you're on Leopard, you can use the command-line version.) Static analysis allows you to find a great many problems without even executing your code, and in many cases is much easier to use than Instruments.

Override -retain and -release, then set breakpoints to see who's calling them.

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