In the pre ARC era, I could override retain and release and log the stack trace - and then easily find the place that retains my object and shouldn't.
Now it's forbidden to do so, and sometimes running instruments is not an option (e.g. it crashes as soon as I try to run my app on device, and the bug doesn't reproduce in simulator).
Any suggestions how this can be done in ARC without instruments?
I may not have the final answer, but I will share a technique I decided to try which is a step in the right direction.
With ARC, the compiler will not allow you to ask the retainCount, and it's even smart enough to stop you from doing performSelector:@selector(retainCount). However, I did not give up there, and went one step further to get access to this helpful debugging indicator.
[anInstance performSelector:NSSelectorFromString(@"retainCount")];
This gets past the compiler, and will reveal a little more under the hood. It's not stacks, but with prolific logging of this value, you can get some hints.
I'm probably about to give up on it, but I am playing with an even trickier (read: uglier) technique to get stacks. The basic idea is to "extend" the retain method via the objective-c runtime, with either class_addMethod() or method_setImplementation. I'll give fair warning that so far it's given me little hope that I will get it working, and I may soon just fall back to more frequent logs of the above performSelector call.
Good Luck!
edit Since I wrote this, I have discovered the Core Foundation functions:
NSLog("RetainCount: %ld", (CFGetRetainCount((__bridge CFTypeRef) anInstance));
Which may not work in all cases, but most, for sure. See The documentation.