James Raitsev
James Raitsev

Reputation: 96391

How to determine object's owner in Objective-C program?

Are there any tools available as part of XCode4 that per given object will tell you "who owns it at any time?"

Upvotes: 1

Views: 695

Answers (1)

bbum
bbum

Reputation: 162712

Yes. The Allocaitons instrument can answer that. Turn on retain count tracking and run your app. You can then click through any object (you'll typically only want to track live allocations) and see an inventory of all retains/releases related to that object.

All retains not balanced by a release from the same object indicates an ownership relationship.

It isn't 100% precise, but it works well enough (and is improving with each release).

Upvotes: 4

Related Questions