简体   繁体   English

iPad内存使用量不断增加

[英]iPad Memory Usage Constantly Increases

I'm writing an iPad application that uses a lot of video and large PNG animation sequences, taking care to release all resources when they are no longer needed. 我正在编写一个iPad应用程序,该应用程序使用大量视频和大型PNG动画序列,并在不再需要它们时小心释放所有资源。 Instruments shows no memory leaks, and allocations shows the app never allocates more than about 30 MB. 仪器显示没有内存泄漏,并且分配显示应用程序分配的内存从未超过30 MB。 However, when I look at Activity Monitor, I see that the real memory and virtual memory is constantly increasing the more one delves into the application's content. 但是,当我查看“活动监视器”时,我发现真正的内存和虚拟内存在不断增加,而更多地关注应用程序的内容。 I put NSLogs in all of my dealloc methods, and every object I release is being deallocated. 我将NSLogs放入所有我的dealloc方法中,并且释放了我释放的每个对象。 My app, however, is getting killed with a signal 0. Does anyone have any suggestions? 但是,我的应用程序被信号0杀死。有人建议吗?

You may be doing this already, but when using the Allocations instrument, take "Heap Shots" as you interact with the UI. 您可能已经在执行此操作,但是在使用“分配”工具时,请在与UI交互时获取“堆快照”。 This will give you an idea of what's being allocated during each interval and the object's lifecycle. 这将使您了解在每个时间间隔内分配的对象以及对象的生命周期。 Bill Bumgarner has an excellent blog entry about this powerful tool that's well worth a read. Bill Bumgarner在有关此功能强大的工具的博客文章中非常出色 ,非常值得一读。

Could it be that you have NSZombieEnabled? 可能是您拥有NSZombieEnabled吗? Happened to me one time... 发生过一次

The WWDC 2011 session 318 video "iOS Performance in Depth" (about 43 min 50 seconds into it) describes how animating UIImage(s) in UIImageView can use up lots of memory. WWDC 2011的第318节视频“ iOS Performance in Depth”(大约43分钟50秒)描述了如何在UIImageView中对UIImage进行动画处理会占用大量内存。 They suggest when animating large images using 他们建议在使用

- (void) animateImages
{
   CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(animateImage:)];
}

- (void) animateImage:(CADisplayLink *)link
{
   [imageView setImage:[UIImage imageWithContentsOfFile:nextImagePath()]];
}

The animation speed isn't guaranteed. 无法保证动画速度。 Using +[UIImage imageWithContentsOfFile:] is key since +[UIImage imageNamed:] will cache image instances. 使用+ [UIImage imageWithContentsOfFile:]是关键,因为+ [UIImage imageNamed:]将缓存图像实例。

I've used this technique in my app that kept running out of memory switching between sets of large image animations and things are working fine and smooth on an iPhone 3GS and iPhone 4S. 我在我的应用程序中使用了此技术,该技术在用尽大内存动画之间切换时会耗尽内存,并且在iPhone 3GS和iPhone 4S上一切正常且流畅。 It's slow on the iPhone 3GS but the 3GS couldn't even do one set of animations before. 在iPhone 3GS上速度很慢,但3GS以前甚至不能做一组动画。 Looking at the Dirty Size stat in VM Tracker the difference is dramatic. 查看VM Tracker中的Dirty Size统计信息,差异是巨大的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM