iPhone、iPod 和 iPad 中的后台处理?

发布于 2024-12-22 18:22:02 字数 344 浏览 5 评论 0原文

在 iPod 或 iPad 设备中,当应用程序正在运行并且用户按下主页按钮时,该应用程序将进入后台 - 但它仍然占用一些内存。 如果许多其他应用程序同样占用越来越多的内存,会发生什么情况? 就我而言,我的应用程序崩溃并出现内存警告 - 是否有我应该使用的解决方案或特定技术?

简而言之, 实际上,我打开一个 Cocos2D 应用程序一段时间后,我会进入主屏幕图标,之后我打开第二个 cocoa2d 应用程序,我驱动当前应用程序的内存非常少。我的意思是,假设第一个应用程序占用 80MB RAM,而其他应用程序占用(总设备 RAM 内存 - 80MB)。这可能吗? id 是的 那为什么呢?我如何解决这个问题,因为由于第一个应用程序,我将无法驱动第二个应用程序

In iPod or iPad devices, when an application is running and the user presses the home button, the app goes into the background - but it still occupies some memory.
What happens if a number of other apps take up more and more memory similarly?
In my case, my app crashes with a memory warning - is there any solution or particular technique I should use?

In brief,
actually i open one Cocos2D application after some time i will come in home screen icon and after that i open second cocoa2d application i got very less memory to drive this current app. I mean suppose if 1st app takes 80MB RAM and other application take (total device RAM memory - 80MB). can it possible ? id yes then why? How i tackle this problem becoz due to 1st application i will not able to drive 2nd application

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

起风了 2024-12-29 18:22:02

您应该做的第一件事是阅读与 应用程序状态响应 iOS 中的低内存警告

WWDC 2010/11 中的“采用多任务处理”视频

另请参阅 返回并询问您是否还有其他问题。

The first thing you should do is read the Apple documentation relating to App States and Responding to Low-Memory Warnings in iOS

Also see the Adopting Multitasking videos from WWDC 2010/11

Come back and ask if you have any more questions.

孤蝉 2024-12-29 18:22:02

你是对的,运行的应用程序越多,使用的内存就越多,如果操作系统决定需要释放一些内存,它可能会杀死你的应用程序。除了在应用程序进入后台时保存应用程序的状态(无论如何你确实应该这样做)之外,你对此无能为力。永远不要假设你会留在后台。

you're right in that the more apps that are run the more memory is used, and if the OS decides it needs to free some memory it could kill your app. there's nothing you can do about this, apart from saving your application's state when the app enters the background (you really should do this anyway). never assume you'll stay resident in the background.

思慕 2024-12-29 18:22:02

当您的应用程序进入后台之前,您应该保存应用程序状态和数据。

You should save your app status and data when your app before your app goes into the background.

淡墨 2024-12-29 18:22:02

如果您希望您的应用程序在后台运行有限的时间,并且已设置适当的后台模式 plist 键,则您的应用程序必须最大限度地减少其内存占用,以便操作系统不会终止它。释放除后台运行所需的最低资源之外的所有内容,最好只释放几 MB 的脏内存。由于您无法在后台显示任何内容,这意味着释放所有视图、UI 资源和图像等,直到您的应用程序再次激活。

If you want your app to run for a limited time in the background, and have set the appropriate background modes plist keys, your app must minimize it's memory footprint in order for the OS not to kill it. Release everything except the bare minimum resources required to run in the background, preferably to only a few MB of dirty memory. Since you can't display anything in the background, that means releasing all views, UI assets and images, etc. until your app becomes active again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文