基金会和基金会的内存泄漏CF网络库

发布于 2024-08-30 03:42:43 字数 214 浏览 3 评论 0原文

我正在使用仪器来解决 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笔芯 2024-09-06 03:42:43

几乎可以肯定,内存泄漏来自您的代码——只要您在设备上进行测试,基础库中几乎没有内存泄漏(模拟器中存在内存泄漏,因此您应该始终在设备上进行测试) 。泄漏的来源并不总是显而易见的,而且很难从你的问题中看出,但我猜它要么来自泄漏 NSStringNSStrings 是用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 with NSCFString under the hood) or a network-related class like NSURLConnection.

九八野马 2024-09-06 03:42:43

我遇到了与内存泄漏相同的问题,这些问题都指向 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文