ARC circular retain detection

后端 未结 3 884
Happy的楠姐
Happy的楠姐 2020-12-28 21:59

I ported some old code over to Objective-C ARC (Automatic Reference Counting) and it seems to work great. Except a rather large, high-level object is not being deallocated

3条回答
  •  心在旅途
    2020-12-28 22:25

    I just transitioned an older app to use ARC. Instruments showed no leaks, but the allocations continued to go up. I found that by looking at the live objects for something that I knew should be deleted, I was able to track down the retains without a release. Here are the basic steps:

    1. Use the Allocations tool in Instruments
    2. Play with your app for a while (if you know what isn't being released, this goes faster)
    3. Change Statistics to Objects in the Allocations jump bar
    4. Sort by Category and find the class name of your unreleased object
    5. Find a living instance and click the little right arrow next to the memory address
    6. Now you can see the history of retains and releases for an object

    Screenshot of object history in Instruments

提交回复
热议问题