iOS, iPhone, iPad: is slow loading a good strategy to avoid memory crashes?
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开发者_如何学C 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?
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.)
精彩评论