1. 6
    1. 5

      Great article, thanks for posting it! The date on it is 2013, not 2016; I wonder what parts of it are out of date by now.

      Unlike a desktop, wherein virtual memory can “spill over” to external storage, the same does not hold true [on ios] (largely due to limitations of flash memory)

      I wonder about that. Nowadays desktop systems are almost all flash-based too, and I assume the same type of flash (iOS storage is about as fast as typical desktop SSDs), so it seems unlikely that limitations of flash are to blame. And current iOS devices come with tons of storage, more than enough for VM swap space.

      I think the reason iOS kills apps rather than swapping them out is because the UI only displays one app at a time (maybe sometimes two, if you’re that rare person who actually knows how to use iPad multitasking.) Since iOS apps tend to launch quickly and restore their state, it makes sense to swap them out on a process level rather than a memory-page level. It’s usually barely noticeable when you switch back to an app and it has to relaunch.

      1. 3

        The iOS policy is also a little bit about garbage collection. The fastest GC that you can build on a *NIX system is exit. This collects all of your memory in a tiny amount of time. Because Objective-C is a superset of C, and C makes an object’s address available as a convenient identifier for hashes / comparisons, you can’t add a copying GC to Objective-C and so you’re likely to see fragmentation over time. If you kill the process, collect all objects, and then recreate the ones that you actually need, it improves locality.

        macOS also uses the sudden-termination support that was added for iOS. Applications notify the OS that they’ve saved all important state (and a lot of GUI state is saved by Cocoa automatically) and they will be quietly killed if the user doesn’t switch to them. The window server keeps the contents of their windows as textures and when the user does try to switch to any of them again they’re displayed immediately and the application is restarted in the background and resumes ownership of the windows. You can sometimes see a jerk when this happens. For example, Preview used to store which page of a PDF you were reading, but not where and so if you switched away, used a load of memory, and switched back, you’d see a short pause and then the view would jerk to the top of the page.

      2. 2

        Yes I saw a video of someone swiping (killing) apps on an iPhone to ‘clean up’ the memory. I don’t think they realised that this is done automatically as memory is needed for ‘in use’ apps, and that most of what they swiped was just screenshots.

        1. 2

          Android people do it also. I had to stop family members from doing so after they didn’t want to much “Backgroind stuff” and a “clean system”. Which obviously ended up creating slower a system.

        2. 2

          This is apparently a meme that was probably started back in the OG iPhone days.

          Some people might just like to keep things “neat” though. It’s a bit like a digital fidget spinner.

      3. 1

        At the bottom it mentions an update in 2016. But yeah it’s unclear how much has changed since.

        On macOS I’ve noticed swapping seems more aggressive than Linux, it tries to keep more RAM available, but that’s in limited situations/configurations.