How can I determine which objects hold references to other objects that are causing memory leaks in objective-c?(如何确定哪些对象持有对导致 Objective-c 内存泄漏的其他对象的引用?)
问题描述
我尝试使用泄漏工具,并分析"等来查找泄漏,但找不到它.使用分配我可以确定没有被释放的对象.
I have tried using the leaks tool, and "analyze" etc to find the leak, but it can't find it. Using allocations I can determine the objects which are not being released.
我注意到(通过在 dealloc 方法中添加调试语句),不会为这些对象调用 dealloc.
I have noticed (by adding debugging statements in the dealloc method), that dealloc is not called for these objects.
如何确定哪些对象持有对这些对象的引用并阻止它们被释放?
How can I determine which objects are holding references to these objects and preventing them from being released?
推荐答案
分析工具无法检测到问题.使用分配工具捕获所有引用计数是一个开始,但是有很多类我不认识或直接访问,我无法使用这种方法追踪问题.相反,我列出了我直接负责的课程,并逐行调查,直到发现问题.原因是我使用了一些第三方库,它们没有按预期减少我的一些对象的保留计数.我想在这种情况下,遵循更好的软件工程原则/设计模式,并进行彻底的代码审查可能会更早发现问题.
The analyze tool was unable to detect the problem. Using the allocations tool to capture all the reference counts was a start, but there were so many classes I didn't recognize, or access directly, I was not able to track down the problem using this method. Instead, I made a list of the classes that I was directly responsible for, and investigated each of them line by line till I found the problems. The cause was that I used some third party libraries which didn't decrement the retain count of some of my objects as expected. I guess in this case, following better software engineering principles / design patterns, and having thorough code reviews may have caught the problem earlier.
这篇关于如何确定哪些对象持有对导致 Objective-c 内存泄漏的其他对象的引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何确定哪些对象持有对导致 Objective-c 内存泄漏的其他对象的引用?
- android 4中的android RadioButton问题 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01