2

In a certain portion of code - I am expecting an object to be dellocated but it isn't.

Given that object - how can I check which objects are referencing it?

Also - Is it possible to know every time an objects reference count goes up? (and by which object)

Avba
  • 14,822
  • 20
  • 92
  • 192
  • 1
    Use Instruments and the allocations tool. https://developer.apple.com/library/Mac/documentation/AnalysisTools/Reference/Instruments_User_Reference/AllocationsInstrument/AllocationsInstrument.html – Wain Feb 10 '14 at 13:47
  • 1
    The better Instruments link is this one: https://developer.apple.com/library/Mac/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/MemoryManagementforYouriOSApp/MemoryManagementforYouriOSApp.html#//apple_ref/doc/uid/TP40004652-CH11-SW2. – Rob Napier Feb 10 '14 at 13:52

1 Answers1

2

You cant check it. Rather you should use instruments to check the same. They will show the retain count of the object. Perform the steps by running the app on instrument and check for retain count.

Even you should not use retainCount method to check. There is no way to identify that which objects are pointing to you object.

Apurv
  • 17,116
  • 8
  • 51
  • 67
  • Then how should I debug this? I know that the reference count is > 1 because dealloc is never called - thats why I need to know who is referencing it – Avba Feb 10 '14 at 13:52
  • Check for instrument memory leak. It will take you to the place which object is holding the reference and not deleting it. – Apurv Feb 10 '14 at 13:53
  • I'm assuming instruments is using the runtime somehow isn't it? – Avba Feb 10 '14 at 13:55
  • ok ill try it. thanks - usually I don't have much success with that tool – Avba Feb 10 '14 at 14:11