views:

1122

answers:

2

To be clear, this is for a normal iPhone application, and not a game.

I've read around the web a few times some developers mentioning that they were working hard to improve/reduce the startup time of their applications, but never with any good background information on how to do so.

So the question is simple: how can you reduce the startup of iPhone applications?

+5  A: 

Same as any other performance issue: Use Shark and/or Instruments to identify bottlenecks in your code, and then focus on how you can speed things up there. Each tool will give you a picture of how much time was spent in what parts of your code, so the general scheme would be to run the tool while you start the app and then pore over the data to see where the performance hits occur.

At app startup time, the most likely candidates for improvement will be deferring data loading until later on when it's actually needed, variously described as "on demand" or "lazy" loading. Essentially, don't load any data at app startup unless it's actually needed right away when the app loads. In practice, lots of stuff that may be needed at some point doesn't have to be immediately available when the app starts. For example, if you have a database of N records but only one is visible at a time, don't load all N into memory at app startup time. Load whatever the current record is and then load the others when you actually need them.

Tom Harrington
A: 

I'm observing a 5 - 6 second lag (of screen blackness) from touch the icon to "main" being called.

After this is when I believe my NIB-based objects are being instantiated/initialized.

I have not found an explaination for what eats this initial 5 seconds, but after that the bulk of the delay (before applicationDidFinishLaunching) is NIB objects being deserialized.

Check for static object instances being initialized before your main() is called.
Julio Gorgé
I've noticed this as well. As my app gets more complex, I've about doubled the NIB-based views I'm creating with Interface Builder. Before `applicationDidFinishLaunching` is even hit, there's a very lengthy delay.
Rob S.
I agree. I think there's a way of solving this: use loadView method on all of your view controllers, because creating objects is much faster than loading them from the memory.
tadej5553