UIImagePickerController不释放它占用的内存 [英] UIImagePickerController does not release memory it occupies

查看:166
本文介绍了UIImagePickerController不释放它占用的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在为我的应用程序使用乐器时看到了这个问题。当我分析我的应用程序时,占用的初始内存是 563 KB ,这是在 UIImagePickerController 弹出之前。第一个viewController上有一个按钮,它会显示 UIImagePickerController

只要 UIImagePickerController 出现,内存占用率达到 1.6 - 1.7 MB 。如果我选择任何图像或取消 UIImagePickerController ,占用的内存仍然是 1.6 - 1.7 MB ,我相信应该 563 KB (或者可能是几KB以上)。

请参阅我使用的以下代码:

I saw this thing on using instruments for my app. When I profile my app, the initial memory occupied is 563 KB which is before UIImagePickerController pops up. There is one button on the first viewController which makes the UIImagePickerController appear.
As soon as UIImagePickerController appears, memory occupied goes upto 1.6 - 1.7 MB. If I select any image or cancel the UIImagePickerController, the memory occupied is still 1.6 - 1.7 MB which I believe should be 563 KB(or may be few KB's more).
Please see the below code I have used :

- (IBAction)chooseButtonPressed:(id)sender
{
    UIImagePickerController *pickerController = [[UIImagePickerController new]autorelease];
    [pickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    [pickerController setDelegate:self];
}  

为什么内存没有被释放?

Why is the memory not being released?

推荐答案

我们无法在评论中添加图片,所以我将此作为答案。 实时字节始终小于总字节数,直到第一次释放内存为止。这可以从下图中看到。

We can't add images to comments so i'm putting this as an answer. The Live Bytes are always less than the Overall Bytes except till the first time a memory is deallocated. This can be seen from the image below.

我认为你的释放没有任何问题。我认为你只是看错了值!

I don't think there's anything wrong with your deallocation. I think you're just looking at the wrong values!

编辑 - 我认为问题可能出在其他地方。要查看我看到的值,您需要做一些改变。如下图所示,您需要取消选中仅跟踪活动分配选项以查看您要查找的值。如果你仍然在活动分配中看到7.41 MB,那么问题就出现了。

EDIT- I Think the problem might be somewhere else. To see the values I was seeing, you need to make a little change. As shown in the image below, you need to uncheck the option Only track active allocations to see the values you're looking for. If you still see 7.41 MB in Active allocations, then the problem is something else.

这篇关于UIImagePickerController不释放它占用的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆