Reputation: 6688
I am struggling to determine what is holding on to objects that I am removing from the view hierarchy and setting to nil (and to the best of my knowledge setting all delegates to nil and removing all notifications) using Instruments Allocations and/or Leaks.
I have the option "Record Reference Counts" enabled, but I do not see where that information is presented. There is no RefCt column in my view (see attached image). How do I make it appear? I am using Xcode Version 8.0 (8A218a).
Is there anyway to analyze what objects are retaining sub-objects?
Upvotes: 5
Views: 2173
Reputation: 1806
As of XCode 13.2...
The screenshot in the question looks like it's using the Leaks tool. Instead, after you choose Product/Profile from the XCode menu bar, choose "Allocations" instead of "Leaks."
When you press the "Record" button, do not let up on the press. You will see an option for "Recording Options" which you should select. In the dialog that appears, select the "Record reference counts" option and then press "Record."
In the bottom left of the Instruments app, there is a filter. Type the name of the class in which you are interested. If there are any active instances of that class, you should now see a row for it in the main panel with the class name listed in the "Category" column. Drag your mouse pointer over the name in the main panel. An arrow button should appear next to the name. Click it.
Then you will be presented with the active instances of that class. You will see an "Address" column. Do the same that you did previously with the "Category" column by dragging your cursor over the address of the active instance (or one of the active instances if there are multiple) and click the arrow button that appears.
Now you will finally see a table that shows the retains and releases of your object which includes a column for "RefCt"
Upvotes: 3
Reputation: 63369
Use the Xcode visual memory debugger. It's covered in this keynote.
Upvotes: 2