Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding all references to an object instance in Obj-C

I'm trying to track down some bugs, and one of them is related to a memory leak. It's an object that I can tell that something still has a reference to, since Instruments still shows it as being alive, but Instruments does not register it as a leak.

Is there anyway to look at an instance of an object in Objective-C and see what other objects still have a reference to that object?

like image 840
Josh Buhler Avatar asked Aug 08 '11 21:08

Josh Buhler


1 Answers

I would recommend using the Allocations/ObjectAllocations Instruments template and then in the top right corner type the class name of your object (in the Category field).

You can then see the allocations increasing as you suggest and by viewing the extended detail you can see where they were allocated.

All content below this point was added by the OP (joshbuhler)

In the screenshot below, change the filter to "Objects List", and then by clicking on the little arrow to the right of the object's address, the history of memory events (alloc/retain/release/dealloc) will be show for that object. It won't show you exactly what is hanging onto that object, but it will give you some very useful info for tracking it down.

enter image description here

like image 62
InsertWittyName Avatar answered Oct 20 '22 16:10

InsertWittyName