iphone 3gs 内存警告 通话查询
嗨,我只是想知道这一点:iphone 3gs 和 iphone 4 何时会发出内存警告,
我的意思是,在我们的应用程序使用了多少内存后,这两个设备都会发出警告?
谢谢
hi i just want to know this: When will iphone 3gs and iphone 4 send out memory warnings
i mean after how much memory our app uses does the both devices send warnings?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不知道它什么时候会火。您不知道后台运行的其他应用程序、保存网页的 Safari 等使用了多少内存。Pandora 可能在后台进行流式传输,并且可能使用大量内存。不要指望任何单一的内存量。延迟加载,并在 didRecieveMemoryWarning 中释放不需要的分配。
如果您的应用程序需要大量内存,一些游戏开发人员会告诉用户在玩游戏之前重新启动设备,以确保应用程序获得最大内存和最佳性能。
You don't know when it will fire. You don't know how much memory is being used by other apps running in the background, Safari keeping webpages, etc. Pandora might be streaming in the background and it might be using a significant amount of memory. Don't count on any single amount of memory. Load lazily, and release uneeded allocations in didRecieveMemoryWarning.
If your app requires a lot of memory, some game developers tell their users to restart the device before playing to ensure the most memory for the app, and best performance.
它没有严格定义,但 Apple 建议您不要使用超过 24MB 的图形内存,因为图形内存的过度使用通常是应用程序收到内存不足警告的原因。
管理 iPhone 上的严重内存不足情况的唯一好方法是实现
didReceiveLowMemoryWarning
委托方法并在此时释放尽可能多的内存。例如,这意味着:如果您的应用程序能够在稍后阶段重新加载该信息,这当然可以安全地完成。然而,
didReceiveLowMemoryWarning
是应用程序的最后手段。为了避免达到这一点,建议仅在需要时延迟加载资源,并在不再需要时释放它们(例如在所有控制器上实现
viewDidUnload
)。It is not strictly defined but Apple suggests you don't use more than 24MB of graphical memory as overuse of graphical memory is typically why an application receives a low memory warning.
The only good way to manage critical low memory situations on the iPhone is to implement the
didReceiveLowMemoryWarning
delegate methods and release as much memory as possible at that point. This means for instance:This can of course be done safely provided your application is able to reload that information at a later stage.
didReceiveLowMemoryWarning
is however a last resort situation for your application.To avoid getting to that point it is recommended to only load resources lazily i.e. when and only when you need them, and release them when they are no longer needed (for instance implementing
viewDidUnload
on all your controllers).