★ TouchArcade needs your help. Click here to support us on Patreon.

A explanation to iOS multitasking.

01-03-2012, 08:59 PM
#1
Joined: Oct 2010
Posts: 307
A explanation to iOS multitasking.

First things first: Open up Resource Monitor on Windows 7.

Switch to Memory tab. How much true free RAM do you have? How much standby RAM?

Now, open Task Manager. How much free RAM does it say you have? Does it match up with resource monitor? No. Task Manager counts Total RAM minus In use. Resource monitor counts free as useless RAM that does nothing. (SBSettings does the bad task manager approach)

'In use' is for what's actually used.

'Standby' is what isn't running, but is already loaded to speed up the system.

'Free' is wasted RAM. An efficient OS will maintain as little free RAM as possible, to speed up the system.

You might be thinking, how does less free RAM mean that the system is faster?

Let's say you launch a game. It needs to load all the textures, binary code, into RAM. A good OS will have already loaded the data into RAM BEFORE* you launch, so you don't wait much. A bad OS will load the data into RAM when you launch, so you have to wait for the hard drive to spin and load it into RAM.

*Windows 7 predicts what you'll need next, and preloads it into RAM as "standby" mode.

What if you launch a different game? The pre-loaded data will be simply overwritten, causing no performance penalty.

-- Back to iOS --

Due to the limited RAM of iOS, we can't go around and predict what apps the users will launch next. What we can do is store last accessed app's state into standby RAM.

When you quit (press home button) an app, one of the two things happen:

a) The app executes for roughly 3 seconds before iOS forcibly quits the application, and stores the state of the app in RAM as "standby". No CPU usage, and RAM is effectively freed, while multitasking back will cause you to restore the state of the app.

b) The app uses special APIs and runs in the background. This is for 1% of the apps like Skype, Pandora radio, accessories...

When you launch an application that requests more RAM than "free" RAM, iOS finds the last used apps that is in "standby" RAM, and overwrites standby RAM with the needed content.

To actually find out memory usage, look at active ram that is in use, not active + inactive.

Last edited by Xapped; 01-03-2012 at 09:03 PM.
01-03-2012, 09:09 PM
#2
Interesting. Thanks for posting this. So what you are saying that there is no drop in performance if you don't completely close your apps?
01-03-2012, 09:45 PM
#3
Joined: Oct 2010
Posts: 307
Quote:
Originally Posted by Shankopotamus View Post
Interesting. Thanks for posting this. So what you are saying that there is no drop in performance if you don't completely close your apps?
There is a tiny performance penalty (Finding earliest used standby RAM), but that should be done in less than a couple of milliseconds.

This isn't the case with special apps like Skype and TomTom through, as they're exceptions and run in the background*.

*Actually Skype doesn't run in the background, iOS still puts it into standby RAM but iOS also creates new sockets that resumes skype when there's something new.