将 AdBannerView 添加到应用程序会导致内存泄漏

发布于 2024-09-14 11:34:49 字数 900 浏览 3 评论 0原文

我有一个使用 SDK 4.0 的 iPhone 应用程序。它显示“Instruments”工具中没有泄漏,并且我相当确信该代码没有任何内存泄漏。

然后我尝试将 iAds 添加到应用程序中,但它开始显示内存泄漏。为了解决这个问题,我删除了所有附加代码。

剩下的就是向 .xib 文件添加 AdBannerView(无需对没有 iAds 的代码工作版本进行任何修改)。这表明存在内存泄漏。

每次加载视图时,“Instruments”工具都会显示 5 个泄漏块,每个块 16 字节,其中包含责任库“Foundation”和责任框架

[NSCFString copywithZone:]

进一步运行该应用程序会从责任库“iAd”中泄漏(2 个泄漏,共 48 个)每个字节)和负责的框架:

[AdBrandingFrame initWithFrame:]

此外,我还通过负责的库“UIKit”和负责的框架获得了 48 字节泄漏,

-[UIView _createLayerWithFrame:]

因为除了在 .xib 文件中添加了 AdBannerView 之外,我的工作非泄漏代码绝对没有任何其他内容,我想知道是否是Apple的代码导致了泄露。虽然漏洞比较小,但我想把它解决掉。我知道即使可能没有泄漏,也有可能出现泄漏(指针可能仍由操作系统以泄漏不知道的某种方式保存 - 很高兴知道情况是否如此)。

所以我有两个问题:
1)是否有可能问题实际上是我的代码,并且由于某种原因泄漏仅在添加 AdBannerView 后才出现?如果有这种可能性,我会再进行一次彻底的代码测试。

2)如果这是Apple代码的问题并且你们中有人遇到过这个问题,您是否找到了解决方法?

任何帮助将不胜感激。谢谢!

I have a working iPhone app using SDK 4.0. It shows no leaks in the 'Instruments' tool, and I am fairly convinced that the code does not have any memory leaks.

I then tried to add iAds to the app, and it started showing memory leaks. In order to nail down the problem, I removed all additional code.

All that is left is an added AdBannerView to the .xib file (without doing a single modification to the working version of the code without iAds). This shows memory leaks.

Every time the view loads, the 'Instruments' tool shows 5 leaked blocks of 16 bytes each, with the Responsible Library 'Foundation', and Responsible frame

[NSCFString copywithZone:]

Further running the app gives me leaks from the Responsible library 'iAd' (2 leaks of 48 bytes each), and the responsible frame:

[AdBrandingFrame initWithFrame:]

Further, I also get 48 byte leaks with the responsible library 'UIKit' and responsible frame

-[UIView _createLayerWithFrame:]

Since there is absolutely no addition to my working non-leaking code, except an added AdBannerView to the .xib file, I wonder if it is Apple's code that causes the leak. Although the leak is relatively small, I would like to iron it out. I understand that there is a possibility that a leak shows up even though there may not be one (the pointers might still be held by the OS in some way that Leaks does not know about - It would be great to know if this is the case).

So I had two questions:
1) Is there any chance the problem is actually my code, and the leak for some reason only shows up after adding AdBannerView? If there is such a possibility, I would run another thorough code test.

2) If this is a problem with Apple's code and any of you have encountered this, are there any workarounds you have found?

Any help would be greatly appreciated. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

潦草背影 2024-09-21 11:34:49

我刚刚遇到了同样的问题。我认为这个问题已经在 IOS 4.1 中修复了
当我在 4.0 中测试时,我遇到了一些泄漏“NSCFString copyWithZone”
在 4.1 中测试时一切都很好。

I just had the same issue. I think this has been fixed in IOS 4.1
When I test in 4.0 I got a couple leaks "NSCFString copyWithZone"
When testing in 4.1 all is good.

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