处理 UIImagePickerController 以最小化内存使用

发布于 2024-09-05 12:03:34 字数 826 浏览 3 评论 0原文

所以,我已经阅读了关于UIImagePickerController、UIImage、内存等的SO帖子,并且我阅读了关于iPhone中UIImagePickerController的内存泄漏问题的文章。在这两篇文章之间,我的记忆效率大大提高了,我感谢 OP 和提供答案的人。

我刚刚对内存泄漏问题中提供的答案有疑问,(本质上)是:

整个程序运行时只有一个控制器实例

在不导致内存泄漏的情况下解决此问题的最佳方法是什么?现在,我正在启动它并在视图内每次使用时释放它,并且我确切地看到了答案所描述的内容(内存警告和大约 20 次使用后的崩溃)。我应该在需要时启动 UIImagePickerController ,但使用与视图无关的单独类来控制它吗?如果我这样做的话,我应该如何处理释放控制器?

--编辑--

根据答案,泄漏已修复。我的崩溃一定是由于内存管理不善造成的。在此处发布了一个新问题来解释新问题话题。

So, I have read the SO post on UIImagePickerController, UIImage, Memory and More, and I read the post on Memory Leak Problems with UIImagePickerController in iPhone. I have VASTLY increased my memory efficiency between these 2 posts, and I thank the OPs and the people that provided the answers.

I just had a question on the answer provided in the Memory Leak question, which was (essentially):

only have one instance of the controller throughout the programs runtime

What would be the best way to go about this without causing memory leaks? Right now I am initiating it and releasing it on every use from within the view, and I am seeing exactly what the answer describes (Memory warnings and a crash after about 20 uses). Should I initiate the UIImagePickerController when I need it, but use a seperate class unrelated to the view to control it? How should I deal with releasing the controller if I do it this way?

--EDIT--

As per the answer, the leak was fixed. My crashes must be coming from poor memory management. Posted a new SO question here to account for the new question topic.

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

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

发布评论

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

评论(1

不乱于心 2024-09-12 12:03:34

将其粘贴到您的应用程序委托中。

不过我很确定这个漏洞在 OS 3 中已得到修复。

Stick it in your application delegate.

I'm pretty sure this leak was fixed in OS 3 though.

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