iOS、iPhone、iPad:缓慢加载是避免内存崩溃的好策略吗?

发布于 2024-12-01 04:47:41 字数 640 浏览 3 评论 0原文

这个问题是这个其他问题。

我在 App Store 上有一款游戏,在 iPad1 上加载时偶尔会崩溃。该游戏是资源密集型的,并且确实在启动时加载了多个大型纹理。重新启动设备即可解决问题。我无法在自己的设备上重现这一点,因此我只有来自少数客户的报告/数据。

(为了这个问题,让我们假设(a)我的应用程序确实需要加载它加载的所有纹理,并且(b)我没有做任何愚蠢的事情,例如泄漏某些东西或不尽早处理某些东西可以。)

问题是:尝试更慢地加载纹理是否有意义?

我的想法是,当我的应用程序启动时加载纹理时,它会开始快速耗尽内存。如果还有其他驻留的应用程序正在耗尽我需要的内存,操作系统将开始向这些应用程序发送通知,告知它们应该释放内存。但我的理解是,它给了这些应用程序几秒钟的时间来释放内存和/或退出,而在这几秒钟内,我的应用程序继续积极加载纹理。所以我的想法是操作系统出现恐慌,需要立即杀死某些东西,并杀死我的应用程序。但也许如果我加载速度更慢,其他应用程序就有时间响应内存警告并释放东西,一切都会顺利进行。

这种想法有道理吗?您是否有使用这种方法来帮助避免崩溃的经验?

This question is a follow-on to this other question.

I have a game on the App Store that, only rarely, crashes when loading on iPad1. The game is resource-intensive and does indeed load up several large textures on start-up. A restart of the device makes the problem go away. I haven't been able to repro this on my own devices, so I only have reports/data from a few customers.

(Let's assume for the sake of this question that (a) my app does indeed need to load all of the textures it loads, and (b) I'm not doing anything dumb like leaking something or not disposing of something as early as I could.)

The question is: Does it make sense to try to load the textures more slowly?

The thinking is that when my app is loading up textures when it starts, it begins using up memory quickly. If there are other apps that are resident and are using up memory that I need, the OS will start sending notifications to those apps that they should release memory. But my understanding is that it gives those apps a couple seconds to free up memory and/or quit, and during those seconds my app continues to aggressively load textures. So the thought is that the OS panics, and needs to kill something right away, and kills my app. But perhaps if I had loaded things up more slowly, the other apps would have had time to respond to the memory warnings and free things up, and everything would have worked out.

Does that line of thought make sense? Do you have experience with that approach helping to avoid crashes?

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

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

发布评论

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

评论(1

迷鸟归林 2024-12-08 04:47:41

关于从一开始就加载所有内容的一个问题:根据您执行此操作的时间,您可能需要很长时间才能启动,并且看门狗计时器会因应用程序无响应而终止您的应用程序。 (听起来这不是发生在你身上的事情,但这是理论上的可能性。很容易在崩溃日志中发现 0x8badf00d。)

One issue about loading everything at the very beginning: depending on when you do it, you can take too long to launch, and the watchdog timer will kill your app for being unresponsive. (It didn't sound like this is what's happening to you, but it's a theoretical possibility. Easy to spot the 0x8badf00d in crash logs.)

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