Tracking object retain calls

Go To StackoverFlow.com

1

How do I track what is retaining my object? I have an object that isn't delloc-ing as expected when it is removed from a list. My suspicion is that something is incrementing the retain count, so I'd like to know how I can ideally create a place to break into the code anytime that object's retain count is incremented.

2012-04-05 21:08
by Joey
Instruments... - CodaFi 2012-04-05 21:09


2

The best possible answer is to use Instruments; it'll track retains/releases all day long.

http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/

If desperate, override -retain to simply return [super retain];. That'll give you a method you can conveniently set a breakpoint on. You could then use breakpoint commands to do something like:

bt
continue

That'll cause the debugger to spew the backtrace of every call, when hit, and then continue.

2012-04-05 21:32
by bbum
Ads