Why does the iPhone need so much less RAM than Android devices?
When comparing an iPhone to other Android powered flagship phones, one thing that tends to stand out, is the significant difference in the RAM storage of the devices. As a result, most people conclude that iPhone needs less RAM or that Android apps hog storage space. But does Android really use more RAM than iOS ?
The first thing we need to establish here, is that we are not talking about storage space. Internal storage space of devices is many a times clubbed together with RAM storage when the specifications are listed. What we are talking about is Random Access Memory (RAM), the memory used by the CPU to hold and execute apps. Below is a comparison between the flagship devices of companies over the past few years.
|2016||iPhone 7: 2GB
iPhone 7 Plus: 3GB
|S7 & S7 Edge: 4GB||G5: 4GB
|Pixel & Pixel XL: 4GB|
|2015||iPhone 6S: 2GB
iPhone 6S Plus: 2GB
|S6 & S6 Edge: 3GB
S6 Edge+: 4GB
|Nexus 5X: 2GB
Nexus 6P: 3GB
|2014||iPhone 6: 1GB
iPhone 6 Plus: 1GB
|S5: 2GB||G3: 2GB (16 GB model)
G3: 3GB (32 GB model)
|Nexus 6: 3GB|
|2013||iPhone 5S: 1GB||S4: 2GB||G2: 2GB||Nexus 5: 2GB|
As you can see, iPhone consistently have lower RAM storage than Android devices with the only exception being the Nexus 5X. The popular opinion regarding this, is that iOS can offer the same if not better user experience by using lesser amount of RAM and this is inherently caused due to Android use of Java’s Garbage Collection Mechanism. This view will be reflected as the most popular opinion on the internet. But the more deeper you look into the problem, the more this opinion starts sounding like a myth.
Resident Set Size
To test the theory that apps on Android use more memory than the ones on iOS, we decided to compare memory usage across the devices. Before we share the results, let us share the thinking behind the results. When an app needs to perform a function such as loading an image, it will request for memory. Say the app asks for 1 MB of memory to load the image. At this point of time, the app’s virtual size will increase, but the system will not allocate memory to it just yet. The actual physical RAM allocating will occur when the app starts loading the image by reading it from storage and then writing it onto the RAM. Thus if only half an MB is used, the actual physical memory used by the app will be lesser than its virtual size.
This physical memory used by the app is termed as the Resident Set Size or RSS and is the best indicator of how much physical memory an app will need to run. Researchers have used a number of tools to identify the RSS needed for various apps on both iOS and Android. To test the claim, the same number of apps were installed on an iOS and an Android device and their RSS was determined. In each case the app was actually being used. Below are the results:
As you can see, it is a bit of a mixed bag. The Crossy Road app on Android uses 383MB of memory, while on iOS it uses 308MB. But conversely Temple Run 2 uses 211MB on Android and 364MB on iOS. Overall the trend is that Android apps use slightly more memory, around 6% more than iOS apps. However iOS apps aren’t half the size of Android apps. Its fair to say therefore, that the claim of Android apps being a memory hog doesn’t hold water. The actual reason cause therefore, is something else entirely.
Background and Foreground
The difference in the storage needs stems from the way the two OSes control background processes. Each of them follows a different approach and hence produce different results. iOS handles moving of an app into the background in 3 different ways:
- An app can request time to complete a task that had begun when it was in the foreground before being pushed into the background.
- Apps that have begun a download process, can pass on these process to the system and therefore can be suspended or terminated while the download progresses unabated.
- Apps that need to run in the background to support a specific task can declare their support for one or more background execution modes.
You can test this yourself. If you own an iPhone, open Safari and hit a URL. While the URL is loading, carry out an action on the screen that causes the screen to render a change. You will notice that the page load has been paused while the screen is being rendered. Android however, approaches background apps with a different methodology.
Android keeps all apps alive on the RAM if there is sufficient RAM to support it. For Android, empty RAM is wasted RAM. This reduces battery usage as the apps are only initialized once and then remain alive on the RAM. Unless these apps have a background process, they do not use any battery while being kept alive. If your device runs out of RAM, then the system will kill off lesser used processes to allow its users to run the apps without worrying.
This difference in approach makes a lot of difference. The restrictions that iOS puts on its apps ensures better RAM management while at the same time keeping the user interface chugging along without any noticeable lag. Android on the other hand allows its apps to enjoy a higher degree of freedom thus allowing them to keep working in the background even though its not being used and this lets a user to get back to an app in its running state with any running tasks unhindered.
On the flip side of this approach, while iOS users might find their apps being in a frozen state when they get back to it, they get to enjoy having their device never suffering from a visible lag whereas Android substitutes this by allowing more processing to be done and thus has a higher requirement of RAM.