使用相机的 UIImagePickerController 出现严重内存问题

发布于 2024-08-21 17:46:38 字数 639 浏览 3 评论 0原文

我注意到,当我加载 UIImagePickerController 并用它拍照时,会调用 didReceiveMemoryWarning 。另外,在 Instruments 中,存在严重的内存泄漏(不是我造成的,我发誓!)。我听说这是 UIImagePickerController 的问题,但是我不知道如何解决它。这是我的 UIImagePickerController 实现。

    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; // Create the imagePicker
    imagePicker.delegate = self; 
    imagePicker.allowsEditing = YES; // Allow editing of the images
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    [self presentModalViewController:imagePicker animated:YES];
    [imagePicker release];

有什么想法吗?我真的不想牺牲这么有用的功能。

I've noticed that when I load a UIImagePickerController and I take a picture with it, didReceiveMemoryWarning is called. Also, in Instruments, there is a significant memory leak (not by me, I swear!). I've heard that this is a problem with UIImagePickerController but, I'm not sure how to fix it. Here is my implementation of UIImagePickerController.

    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; // Create the imagePicker
    imagePicker.delegate = self; 
    imagePicker.allowsEditing = YES; // Allow editing of the images
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    [self presentModalViewController:imagePicker animated:YES];
    [imagePicker release];

Any ideas? I really don't want to sacrifice such a useful feature.

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

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

发布评论

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

评论(2

離殇 2024-08-28 17:46:38

SDK 3.2 有同样的泄漏吗?
我在使用 UIImagePickerController 拍摄视频时也遇到了类似的泄漏。

当我发现泄漏在 3.2 中得到修复时,我决定将应用程序的最低操作系统版本设置为 3.2。

关于内存警告,这是可以预料的。相机需要大量内存来完成其工作,并且只是通过发送 didReceiveMemoryWarning 消息向您的应用程序请求尽可能多的内存。

Do you have the same leak with the SDK 3.2?
I had a similar leak when using the UIImagePickerController to take a video.

When I found that the leak was fixed in 3.2, I decided to set the minimum OS version of my application to 3.2.

About the memory warning, it's to be expected. The camera needs a lot of memory to do its job, and is simply requesting as much memory as possible from your app by sending a didReceiveMemoryWarning message.

您需要将图像重新调整为较小的尺寸,例如 320x460。然后就可以成功运行了。

You need to rescale the image to a smaller size, say 320x460. Then it will run successfully.

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