A explanation to iOS multitasking.

Discussion in 'General Game Discussion and Questions' started by Xapped, Jan 4, 2012.

  1. Xapped

    Xapped Well-Known Member

    Oct 12, 2010
    307
    0
    0
    #1 Xapped, Jan 4, 2012
    Last edited: Jan 4, 2012
    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.
     
  2. Shankopotamus

    Shankopotamus Well-Known Member

    Mar 28, 2011
    550
    0
    0
    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?
     
  3. Xapped

    Xapped Well-Known Member

    Oct 12, 2010
    307
    0
    0
    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.
     

Share This Page