iPhone中的内存管理 [英] Memory Management In iPhone

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

问题描述

我有一个iPad应用程序,显示了大量信息和相关图像。例如:我可以访问事件部分,我可以从中选择一个。每一个都有不同的日期或会外活动。一旦我选择了会外活动,我会收取一些小视图,其中包含新闻标题;作为预览的小图像和ViewController中的短文本(具有ScrollView)。这个预览可以很多。由于我的代码没有泄漏(我使用Instruments进行分析,而且我能找到的唯一一个是由于NSXMLParser错误),但我注意到实时字节不会减慢,只会增长。每次我必须更新ScrollView的内容时,我会负责插入以下代码:

I have an iPad App which shows a whole load of information and related images. For instance: I can access to the section "Events", from which I can choose one. Every single one has different dates or side events. Once I choose the side event, I charge some small views, which contain the title of the news; a small image as a preview and a short text in a ViewController (which has a ScrollView). This previews can be a lot. There are no leaks due to my code (I analized with Instruments and the only ones I can find are due to NSXMLParser bug), but I have noticed that the live bytes don’t slow down, ever, they only grow. Every time I have to update the content of the ScrollView I take care of inserting the following code:

if ( bannerVideo ) { 
  [banner release]; 
  banner = nil; 
}

你有没有机会知道这种不断增长的原因是什么? ?

Do you by any chance know what could be the reason for such a constant growth?

推荐答案

已解决

I将ViewControllerbannerVideo添加为主ViewController的子视图。这会导致retainCount增加1。所以,当我要求一个新视图时:

I added the ViewController "bannerVideo" as a subview to the main ViewController. This causes the retainCount to increase by one. So, when I asked for a new view:

if ( something ) {
  [[bannerVideo view] removeFromSuperview];
  [bannerVideo release];
  bannerVideo = nil;
}

是的,bannerVideo的堆区域的主要访问权限已经发布,但它仍然由主ViewController视图保留。

Yes, the main access to the heap area for bannerVideo was released, but it was still retained by the main ViewController View.

这篇关于iPhone中的内存管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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