Debugging strategies for excessive hold in ARC?

I have some objects that are transferred to a lot of different types and controllers in my application. They are not exempt when I expect them. Obviously, somewhere there is a strange strong pointer, but the surface area where it can be is very large - these objects move to and from many different data structures.

My usual solution is Leaks (which does not report cycles) and Allocations (which lists 500+ save / releases for this object). Is there any way to reduce the search space here?

Ideally, there would be a tool that would allow me to enter a pointer and see all the strong links to the object, and I could probably see the list and find the sitelink in about 60 seconds. In fact, there is such a tool - the Object Graph tool, but it is not available for iOS software.

+7
source share
2 answers

You need the Allocations tool. To track an individual type of object, run the application. You need to create a heap on each significant event (I usually create them at points when you just moved to or from the view controller).

Once you have the heap that the object you are interested in tracking should have, then you can find this type of object in the heap expansion triangle. For each object of this type, you can get a history of what this object saves and releases by clicking the arrow in this line of the object.

+18
source

The easiest way to determine if there is a save cycle or not is by simply setting a breakpoint in your controller dealloc() / deinit() (swift), and whenever you click on your controller, check that these methods are called or not, if there is save the loop present in the controller, this method will not be called.

Swift

 deinit { print("Memory to be released soon") } 

Goal c

 - (void)dealloc { NSlog("Memory to be released soon"); } 

If you want more detailed information about strong links and the main reasons, you should go with the Tool as another answer.

0
source

All Articles