为菜鸟提供使用仪器泄漏的建议

发布于 2024-09-06 08:22:55 字数 1114 浏览 4 评论 0原文

你好,我对 iPhone 开发还很陌生。我第一次使用“Instruments”中的“Leaks”运行我的应用程序。它向我展示了大约 20 个泄漏,最小的是 32 字节,还有一个 1KB。我遵循了内存管理指南,(我(认为我)了解如何以及何时使用释放,而不是在添加到自动释放池时使用它,对于每个副本,保留,初始化都应该有一个释放,...等等) 。我不认为我理解仪器泄漏的输出。 “负责任的图书馆”和“负责任的框架”是什么意思?因为有一些类和方法我从未直接使用过。它还显示了我在 connectionDidFinishLoading 方法和错误处理程序方法中释放的 NSURLConnection 对象。所以从技术上讲,它们是不可能泄漏的。是否有任何好的教程可以调试仪器中的内存泄漏,或者您可以给我有关泄漏的其他建议。提前致谢。

这是最大的 2 个泄漏。

Leaked Object   #   Address Size    Responsible Library Responsible Frame
Malloc 1.00 KB      0x4827400   1024    CFNetwork   std::vector >*, std::allocator >*> >::reserve(unsigned long)

// i have no idea what this is.

Leaked Object   #   Address Size    Responsible Library Responsible Frame
Malloc 128 Bytes    5       640 UIKit   UIImagePickerLoadPhotoLibraryIfNecessary
// so this means UIImagePicker is leaking memory?

我收到的第一次泄漏

Leaked Object   #   Address Size    Responsible Library Responsible Frame
Malloc 128 Bytes        0x442dfd0   128 UIKit   UIKeyboardInputManagerClassForInputMode

我不明白其中任何一个。

我发现很奇怪的是,即使是一个几乎空的应用程序,没有添加任何代码,只有一个视图和一个文本字段也会泄漏内存。

Hello I am pretty new to iphone development. I have run my app for the first time using the "Leaks" from "Instruments". It shows me several leaks around 20 the smallest is 32 bytes and there is one with 1KB. I have followed the memory management guidelines, (i (think i) understand how and when to use release, not to use it when adding to autorelease pools, for every copy, retain, init there should be a release,... etc). I don't think I understand the output of the Leaks in instruments. What does "Responsible library" and "Responsible frame" mean. Because there are some classes and methods i never used directly. It also shows NSURLConnection objects which I have realeased in the connectionDidFinishLoading method and also in the error handler method. So tehnically there is no way for them to leak. Are there any good tutorials for debugging memory leaks in instruments or other advice you can give me regarding leaks. Thanks in advance.

Here are the largest 2 leaks.

Leaked Object   #   Address Size    Responsible Library Responsible Frame
Malloc 1.00 KB      0x4827400   1024    CFNetwork   std::vector >*, std::allocator >*> >::reserve(unsigned long)

// i have no idea what this is.

Leaked Object   #   Address Size    Responsible Library Responsible Frame
Malloc 128 Bytes    5       640 UIKit   UIImagePickerLoadPhotoLibraryIfNecessary
// so this means UIImagePicker is leaking memory?

The first leak i get

Leaked Object   #   Address Size    Responsible Library Responsible Frame
Malloc 128 Bytes        0x442dfd0   128 UIKit   UIKeyboardInputManagerClassForInputMode

I don't understand any of those.

And I find it very strange that even an almost empty app with no code added, just a view and a textfield also leaks memory.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文