[英]ARC circular retain detection
I ported some old code over to Objective-C ARC (Automatic Reference Counting) and it seems to work great. 我将一些旧代码移植到Objective-C ARC(自动引用计数),它看起来效果很好。 Except a rather large, high-level object is not being deallocated when it is popped off of my navigation stack, making me believe I have a retain cycle somewhere that ARC has hidden from me (or at least made difficult to track down). 当一个相当大的高级对象从我的导航堆栈中弹出时,它不会被释放,让我相信我有一个ARC隐藏在我身边的某个保留周期(或者至少很难跟踪)。 What is the best way to weed out this potential retain cycle and/or what is a good way to determine the cause of a memory leak under ARC? 清除这个潜在保留周期的最佳方法是什么和/或什么是确定ARC下内存泄漏原因的好方法? Thanks! 谢谢!
I just transitioned an older app to use ARC. 我只是转换了一个较旧的应用程序来使用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: 以下是基本步骤:
The best way is usually to use the Leaks instrument in the Instruments app . 最好的方法通常是在仪器应用程序中使用Leaks仪器 。
The What's New In Instruments video from WWDC 2011 discusses using Instruments to find retain cycles under ARC, starting about 38 minutes in. 来自WWDC 2011的 “ 什么是新的仪器”视频讨论了使用仪器在ARC下找到保留周期,从大约38分钟开始。
X-code 8 introduced the Memory graph debugging tool: X-code 8引入了Memory图形调试工具:
have a look here for full reference: 看看这里完整的参考:
https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/special_debugging_workflows.html#//apple_ref/doc/uid/TP40015022-CH9-DontLinkElementID_1 https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/special_debugging_workflows.html#//apple_ref/doc/uid/TP40015022-CH9-DontLinkElementID_1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.