使用 Instruments 的 NSMutableArray 的内存泄漏
根据 XCode 中的泄漏工具,它说这一行出现内存泄漏(100%)?
self.unsentPatients = [[NSMutableArray alloc] initWithArray:[defaults arrayForKey:UNSENT]];
我在 dealloc 上正确释放了等(肯定正在运行),所以我不明白我哪里出错了?
这只是一个小泄漏,分析没有得出任何结果,但它仍然是一个泄漏。
亲切的问候,
多米尼克
According to the leak instrument in XCode it's saying this line is giving a memory leak (100%)?
self.unsentPatients = [[NSMutableArray alloc] initWithArray:[defaults arrayForKey:UNSENT]];
I'm correctly releasing etc. on dealloc (which is definitely being ran) so I don't understand where I am going wrong?
It's only a small leak and Analysis doesn't come up with anything, but nonetheless it's still a leak.
Kind regards,
Dominic
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这段代码有很多问题。
我假设该属性保留该值,那么您不应该按照现在的方式分配值,而更像是:
或者
您还应该避免在 dealloc 或中使用
self.
语法init,它将调用一个mutator
。在多线程环境中这可能会产生问题。
所以正确的释放是:
There are many things wring with this code.
I'm assuming that the property is retaining the value, then you should not assign the value the way you are doing now, but more like:
or
You should also avoid using the
self.
syntax in dealloc or init, which will call amutator
.In multithreaded environment this could give problems.
So the correct dealloc would be: