Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

DavidBlack

macrumors 6502a
Original poster
Jan 27, 2013
606
239
Somewhere In Apple's HQ ;)
There’s one bit of iOS misinformation that I keep hearing. Even supposedly authoritative sources such as Apple Geniuses don’t seem to get it. It has to do with how multitasking works in iOS.

Here’s the statement I keep hearing, and it’s wrong:

All those apps in the multitasking bar on your iOS device are currently active and slowing it down, filling the device’s memory or using up your battery. To maximise performance and battery life, you should kill them all manually.

The iOS multitasking bar does not contain a list of all running apps. It contains a list of recently used apps. The user never has to manage background tasks on iOS.

Except in a few cases, which I’ll explain, the apps that appear in the multitasking bar are not currently running. When you press the home button, iOS will tell the app to quit. In almost all cases, it quits, it stops using processor time (and hence battery), and the memory it was using is eventually recovered, if required.

The five faces of apps
iOS apps can exist in any of five states of execution. These are:

Not Running: The app has been terminated or has not been launched.
Inactive: The app is in the foreground but not receiving events (for example, the user has locked the device with the app active).
Active: The normal state of “in use” for an app.
Background: The app is no longer on-screen but is still executing code.
Suspended: The app is still resident in memory but is not executing code.
Active and Inactive are not relevant to this discussion. Most of the confusion is around what happens as an app goes from Active to Background to Suspended to Not Running.

When you press the home button, the app moves from Active to Background. Most apps usually then go from Background to Suspended in a matter of seconds. (Suspended apps remain in the device’s memory. This is so they can resume more quickly when you go back to them. They’re not using processor time and they’re not sucking battery power.)

You may think that if an app is resident in memory, you might have to remove it manually in order to conserve memory. But you don’t: iOS does it for you. If you launch a memory-intensive app such as a game, iOS will start to purge Suspended apps from memory and move them to the Not Running state. That is, they will be completely removed from memory and will launch afresh the next time you tap their icon.

Here’s the confusing part: None of these states are reflected in the multitasking bar. That bar always shows a list of recently used apps, regardless of whether they’re in the Background, Suspended, or Not Running states. (You may also have noticed that the app that is currently Active does not appear in the multitasking bar.)

Background tasks
Let’s take an app that downloads largish files from the Web, such as Instacast, my favorite podcast app. When Instacast is Active, it can start to download new podcasts. By default, if I hit the home button on my iPhone, Instacast would get five seconds to run in the Background state before it would be moved to Suspended. That would interrupt the download of my podcasts, which can take some time. (They’re large files.)

But iOS allows apps such as Instacast, which have time-intensive tasks that can run in the background, to ask for a reprieve. The app declares its downloading of podcasts as a “background task.” This allows Instacast an extra period of Background running, after I hit the home button, to complete its downloads.

Instacast doesn’t have all day. An app gets about ten minutes of Background running time before it is forcibly suspended by iOS. But regardless, this isn’t a feature regular users should worry about.

Indefinite background running
So all apps get five seconds of Background running, to clean things up, and some apps (such as Instacast) can request a ten-minute extension. There are, however, a small number of apps that genuinely need to run indefinitely in the background, and iOS allows this.

There are exactly five kinds of apps allowed to run indefinitely in the Background state in iOS 5:

Apps that play audio while in the Background state. A good example is Instacast while it’s playing a podcast.
Apps that track your location in the background. For example, you still want voice prompts from your turn-by-turn GPS navigation app, even if another app is Active.
Apps that listen for incoming voice-over-IP (VOIP) calls. If you use Skype on iOS, you can receive incoming Skype calls while the app is in the background.
Newsstand apps that are downloading new content.
Apps that receive continuous updates from an external accessory in the background.
All well-written apps in the above categories should become Suspended when they are no longer performing the task in hand. When Instacast finishes playing a podcast, it should be Suspended. There are some built-in apps that also run continuously in the background on iOS—the most-used one is probably Mail.

As long as these apps are running in the Background state, they will consume memory, CPU time, and power. It’s also important to know that an app which is enabled to run indefinitely in the background can do anything that it can do when it’s Active. This may include much more than just playing audio or tracking your location. For example, as long as Instacast is playing audio it can also continue to download new episodes in the background.

In general, though, you would know that you were using such apps. The developer has to declare which category of Background running they require, and part of the App Store review process is to check that these declarations are not being abused—although App Store review is never a perfect catch-all.

I said earlier that “the user never has to manage Background tasks on iOS.” The only exception to this is when one of these Background-running apps either goes berserk or will not Suspend itself properly. In such a case, you may want to manually kill the app from the Multitasking Bar. This, however, is an unusual situation and not a normal part of being an iOS user. I do think, though, that iOS could do a better job of showing which apps are currently in indefinite Background running, perhaps similarly to the way that apps using Location Services are shown.

Summary
Let me wrap this up by giving you a quick summary:

If someone tells you that all the apps in the multitasking bar are running, using up memory or sucking power, they are wrong.
When you hit the home button, an app moves from Active to Background and quickly to the Suspended state, where it no longer uses CPU time or drains power.
An app may request an additional ten minutes of Background running to complete a big task before becoming Suspended.
If memory is becoming scarce, iOS will automatically move Suspended apps into the Not Running state and reclaim their memory.
Five classes of apps—audio, GPS, VOIP, Newsstand and accessory apps—and some built-in apps such as Mail may run indefinitely in the background until they complete their task.
Put simply: You do not have to manage background tasks on iOS. The system handles almost every case for you, and well-written audio, GPS, VOIP, Newsstand, and accessory apps will handle the rest

Taken from Macworld
 
Wow, that's a long post that no one asked for. But thanks for clearing something up that we're all well aware of.

See here's the problem. Many users on here seem to be unaware of this, despite you knowing it. Check some of the battery threads or ones comparing OS's. You'll see a grip of people thinking they must delete the app from the tray in order to preserve battery. I have so many friends, colleagues, and customers who also believe this. Seems they missed the memo sent out way back by Apple explaining what limited services can be run in the background.
 
Thanks for the copy and paste of an article written by Fraser Speirs. I'm not bashing you, but why randomly post this information in a new thread?

His blog - http://speirs.org/blog/2012/1/2/misconceptions-about-ios-multitasking.html

Macworld picked up the article too.

http://www.macworld.com/article/1164616/how_ios_multitasking_really_works.html

Next up...a job at the New York Times.

BTW, when I download an app when or where is it that I'm supposed to see "developer has to declare which category of Background running they require"?
 
Next up...a job at the New York Times.

BTW, when I download an app when or where is it that I'm supposed to see "developer has to declare which category of Background running they require"?

We just include certain key APIs into the app that triggers background capabilities. Apple reviews these prior to approval so people wont just do a fake VOIP simply so their app stays resident.
 
We just include certain key APIs into the app that triggers background capabilities. Apple reviews these prior to approval so people wont just do a fake VOIP simply so their app stays resident.

I see. So that has nothing to do with "In general, though, you would know that you were using such apps." That is, the end user hasn't got a clue what the developer told Apple. Which seems to defeat the whole reason for the article and it's pasting into this thread. If you don't know which ones are using battery or RAM, you have to stop them all!

And that's why a background app killer is one of the first things I'll get when I jailbreak. :D
 
No. You would know by

A. playing sound
B. location arrow
C. You manually initiated VoIP

So no. You would know.
 
I actually didn't know this but I'm also pretty forgetful when it comes to clearing my aps and there would be times where there's a long list of previous aps open and my battery usage doesn't seem to be affected.
 
No. You would know by

A. playing sound
B. location arrow
C. You manually initiated VoIP

So no. You would know.

What about...

D. An app that, upon closing, requests extra time from the OS to finish processing something in the background? I've also heard that you can "chain" these requests together.
 
Apple likely has tools that automate checking for such a scenario.

That's the only app I can imagine this to occur without a users knowledge but it would have to get past the review process.
 
If a developer submits something with this:

Code:
backgroundTaskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{}];

Then Apple reviewers will pay close attention to what it's doing to ensure the app isn't just running it continually. For what gain, I have no idea.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.