基金会和基金会的内存泄漏CF网络库
我正在使用仪器来解决 iPhone 中应用程序的内存泄漏问题。我只是想知道我是否必须解决来自 Foundation 和 CFNetwork Libraries 的泄漏问题。具体来说,泄漏来自:
1.NSCF字符串
2. NSConcreteData
3.通用区块-3584
由于它们不直接指向我编写的代码,如果必须的话,我应该如何解决它们?
谢谢。
I am using instruments to resolve memory leak issues for an app in iPhone. I just wanted to know if I have to resolve the leaks coming from Foundation and CFNetwork Libraries. Specifically, the leaks are from:
1. NSCFString
2. NSConcreteData
3. General Block-3584
Since they do not directly point to the code that I have written, how should I resolve them, if I have to?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
几乎可以肯定,内存泄漏来自您的代码——只要您在设备上进行测试,基础库中几乎没有内存泄漏(模拟器中存在内存泄漏,因此您应该始终在设备上进行测试) 。泄漏的来源并不总是显而易见的,而且很难从你的问题中看出,但我猜它要么来自泄漏
NSString
(NSStrings
是用NSCFString
在底层)或与网络相关的类,如NSURLConnection
。It's almost certain that the memory leaks come from your code--there are almost no memory leaks in the Foundation libraries, providing you're testing on the device (there are memory leaks in the simulator, so you should always test on the device). It's not always immediately obvious where the leak comes from, and it's difficult to tell from your question, but I would guess it either comes from leaking an
NSString
(NSStrings
are implemented withNSCFString
under the hood) or a network-related class likeNSURLConnection
.我遇到了与内存泄漏相同的问题,这些问题都指向 CFNetwork 和 Foundation 框架。一个小修复清除了所有内存泄漏。在使用异步 HTTP 连接时,我遇到了这个问题。
问题:
在委托中,
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse*)
响应中,我复制了 NSURLResponse 并释放。
解决方案:
不要复制和发布NSURLResponse。只需将其用作头文件中的属性 asstype 即可。
I experienced the same problems w.r.to memory leaks which were pointing to CFNetwork and Foundation framework. A small fix cleared all the memory leaks. While using aynchronous HTTP connection, I faced this problem.
Problem:
In the delegate,
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse*)
response,I copied NSURLResponse and released.
Solution :
Dont copy and release NSURLResponse. Just use it as property asstype in your header file.