iPhone 内存变小?
我在我的应用程序中注意到,如果我的手机很长一段时间没有关机,didReceiveMemoryWarning 的调用速度会更快。我的应用程序可以访问的内存池似乎随着时间的推移而缩小。
有其他人注意到这一点并且有解释吗?我可以采取哪些措施来防止这种情况发生?
当我使用大量内存拍摄和操作照片时,我注意到这种情况发生。关闭并重新启动手机会有所帮助。我的应用程序可以访问的内存是否可能正在缩小,或者现有内存是否已碎片化并且重新启动会对现有内存进行碎片整理?
对这个问题的任何解释或帮助都会很棒。谢谢。
I have noticed in my application that didReceiveMemoryWarning gets called much faster if my phone has not been powered down for a long time. It almost seems like the pool of memory that my application can access shrinks with time.
Has anyone else noticed this and is there an explanation for it? Is there a course of action that I can take to keep this from happening?
I notice this happening when I use a good chunk of memory taking and manipulating a picture. Powering down and rebooting the phone helps out. Is it possible that the memory that my application can access is shrinking or maybe the existing memory is fragmented and rebooting defrags the existing memory?
Any explanation or help with this issue would be great. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,不幸的是,这是众所周知的行为。随着操作系统的运行,问题会越来越严重,最终需要重新启动才能解决问题。这就是应用程序商店中的许多应用程序在玩游戏之前请求重新启动的原因。
Yes, this is, unfortunately, well known behavior. As the OS runs, cruft develops, and a restart is eventually required to clear things out. This is why many apps in the appstore request a restart before playing their game.
旧版本的 iPod 守护程序 mediaserverd 曾经存在泄漏问题。
这导致了您所描述的行为。
如果一项系统服务可能发生泄漏,其他系统服务也可能发生泄漏。
Older versions of the iPod daemon, mediaserverd, used to leak.
That resulted in the behaviour you describe.
If one system service can leak, so can others.
仅仅因为我们的应用程序无法进行多任务处理,并不意味着 iPhone 可以进行多任务处理。
在 Safari 中打开的网页会保留在内存中,直到操作系统向 Safari 发送与您收到的相同的内存警告。邮件可能会在您的应用程序运行时开始工作,并且需要更多内存。 iPod 应用程序还为自己保留了相当多的内存。
如果您使用管理器查看 iPhone 的控制台,同时您的应用程序收到内存不足警告,您可能会看到一些内置应用程序也收到内存警告并终止某些操作以释放内存。这很有趣。
Just because we don't get to multitask our apps doesn't mean the iPhone is doing multitasking.
Open web pages in Safari stay in memory until the OS sends Safari the same memory warning you're getting. Mail might start working while your app is running and require more memory. the iPod app is also keeping quite a bit of memory for itself.
If you look at the console of the iPhone using the Organizer while your app getting a low memory warning you'll probably see some of the built in apps also getting memory warning and terminating things to free memory. It's quite interesting.