First, a little theory. What is RAM and what is it for in a smartphone? In simple terms, this is the memory that stores all running applications, their data, and the operating system itself!
Naturally, the more RAM your device has, the more comfortable and pleasant it is to interact with it.
Most iPhone users don't even know how much RAM they have in their smartphone. This is due to the fact that users are comfortable with multitasking in their smartphones, they just use and enjoy the smoothness and speed of work. So how does Apple manage to perform well with 4GB of RAM?
Could it be the system? In fact, miracles do not happen, Android and iOS require approximately the same amount of RAM. For example, a couple of years ago, a foreign Android Authority channel made a detailed comparison. The author took two smartphones on iOS - an iPhone 7 and on Android - a Nexus 5x, with the same amount of RAM - 2 GB. The iPhone 7 has LESS free RAM since launch than an Android smartphone: about 750 MB versus 1.2 GB for the Nexus. But this is until the moment you start any of your applications. We repeated the test on the iPhone 11 and Pixel 3 with Pixel 4. Now the numbers are comparable: the iPhone uses about 2GB of RAM, and the Pixel uses about 2.4GB.
Okay, maybe it's because Android apps take up more RAM space? After all, Apple loves developers, and they reciprocate. But also not: in many cases the size of the occupied space in RAM on iOS and Android is approximately equal, but in some cases applications on iOS take up almost 1.5-2 times less RAM! This is most likely due to the more optimized executable code of the application, because the languages ββfor writing applications are very different.
When calculated, Android apps collectively take up only 6% more RAM space.
But this is just the beginning, as many users of apple products say "Optimization Decides!", As it turned out, there is some truth in this!
Both devices work with applications at lightning speed, everything is clear with an android, everything is stored in RAM, but how does the iPhone cope with its pitiful 4 gigabytes? All the magic lies precisely in the work of iOS with RAM. Basically, both iPhone and Android have approximately the same memory scheduler. If at the time of launching a new application, the smartphone simply does not have free RAM, it will throw out one of the previously launched ones and open the one that you need at the moment!
In the world of computers, the Windows operating system has a swap file (pagefile.sys), also called swap (the term is written in English - swap). This is the space on your hard drive where the system moves unused data from RAM. In order not to store them in RAM, long-running applications are simply transferred to the hard drive, thereby freeing up space for another Chrome tab. PK-boyars understand what I mean.
On smartphones, things are a little more complicated, many smartphones still have not the fastest flash drives in permanent memory. We add to this the fact that flash memory has a relatively small read and write resource, so smartphone manufacturers have resorted to a different implementation!
Imagine such a situation, we have 4GB of RAM, 5 applications are open, the memory is all already full, how can we start another application without closing one of the five, that is, those that are already open. The thing is that both iOS and Android also have the so-called Compressed SWAP - using compression, which is similar to what the archiver does. The application is compressed inside RAM, the system selects the most massive applications, be it one large or two small games, compression occurs, thereby freeing up to 50% more space, and now you can launch another application.
This scheme works on both iPhone and Android, but Apple has gone a step further. They figured out how to divide the space into separate pages - 16 KB blocks that can hold any information. Such a page can be marked as dirty or clean. Clean - memory that is no longer in use (that is, no objects refer to it anymore, and you can safely unload it). Later it can be loaded from disk ("page out"), this memory contains frameworks, executable code and read-only files.
For example, such pages may contain game texture data that is not used by the application even after it has been restarted from the background, as well as in other applications it may be different AR tickers, masks, and other blocks of code that the application does not use until the user is reused. will launch the program from the background.
Dirty - memory that is still used in the application, it is impossible to unload it, therefore, when the application switches to the background, the clean one is simply unloaded, and the dirty one is compressed using two compression methods:
- Buffer Compression - Uses a one-step file compression method, this method is used to compress small files up to 8MB.
- Stream Compression - Uses several steps to compress files, including re-compressing previously compressed files, making it ideal for compressing large files.
Let's say we have an Instagram application, it takes up 300 MB of RAM, the first step will be to clear the clean memory that the application had in stock and will no longer be needed. The size in RAM is reduced to about 170 MB. The operating system will then resort to one of two methods to compress dirty memory. Thanks to a clever compression algorithm, the dirty memory of 170 megabytes is compressed to an impressively small size - less than 10 MB! In turn, manufacturers of smartphones based on Android came out of the situation with a simpler solution, to increase the size of the RAM in order to use less compressed swap. So it's test time. We took devices of different generations - iPhone 11 and Pixel 3 - but both with 4GB. Let's see what happens.
Pixel keeps three games in mind. Started unloading them from memory when starting the fourth.
The iPhone fully supports six games. I started unloading on the seventh, but not all. Everyone started to fly out only in the eighth game.
And here we come to the culmination of the question, you need to understand why the iPhone is compressing data so quickly in RAM? And the point is this. To quickly perform this operation, you need a powerful processor with high performance Big Cores!
If we look at the screenshots from the GeekBench 5 benchmark, we will see the superiority of the A13 Bionic over the Snapdragon 865 by 1.5 times, and the A14 Bionic has not even been released yet! It is performance per data stream that has always been the main trump card of Apple processors! The big problem of Android smartphones is that they are all built on very different hardware, manufacturers are forced to optimize the system for weaker devices that simply do not have such impressive processor power or fast memory. Although there is already some progress from Qualcomm.
So even from the presentation of Snapdragon 855, it was noticed that the company focused on one high-performance core (prime core), which has an increased frequency and cache size, but this is still not enough to catch up with Apple chips.
I think now many have understood why the iPhone does not need so much RAM. Size is not the main thing, it is better to invest more money in the software part, and properly allocate the resources of your hardware due to smart algorithms for compressing files in the RAM.