LightBlog

mardi 29 mars 2016

The RAM Conundrum: How Much RAM Do We Really Need?

Samsung 6GB RAM

Recently, we were treated to announcements of one of the first smartphones running Android that come with 6GB of RAM.

6 freaking GB! That is a lot of RAM in a mobile device.

Starting up the number game is the Vivo Xplay5 Elite. Vivo as a company may not be very well known outside of China, but the company, to its credit, has made some really thin smartphones in the past. With the Xplay5 Elite, they tried to fit in a lot of specs in a device that aims to stand amongst kings.

vivo_xplay_5_elite_front_back_side

The Vivo Xplay 5 Elite features a dual-curved 5.43″ QHD Super AMOLED display on a metallic frame for the body. Inside, there is the latest Qualcomm Snapdragon 820 SoC clocked at 2.15 Ghz, Adreno 530 GPU, 6GB of LPDDR4 RAM and 128GB of non-expandable storage. For camera, the rear is a 16MP Sony IMX298 sensor with f/2.0 and the rear is an 8MP shooter. Keeping in mind these specs and the metallic build of the device, it should be no surprise that it would cost quite some even for the Chinese consumer. With a price tag of CNY 4,288 ($660), this is certainly a Chinese flagship rather than an affordable mid-ranger.

The Vivo Xplay5 Elite is not the only smartphone right now with 6GB of RAM. A lesser known and newly founded Chinese OEM, Vernee, is aiming to bring greater consumer accessibility to gargantuan amounts of RAM by launching a mid-ranged device, the Vernee Apollo.

Vernee Apollo

The Vernee Apollo will come bearing MediaTek’s high end SoC, the Helio X20. There will be the aforementioned 6GB of RAM, 128GB of internal storage, a 21MP Sony IMX230 rear camera and a 5.5″ 2K display. With all of that, the Apollo would cost $399.99. The press information sent to us had no mentions of a Chinese price or of target markets, so the phone is still quite a bit of mystery.

Both of these phones beg us to ask the question, do we really need so much RAM right now?

To answer this question, we have to understand how Android handles memory management and RAM. Mishaal did a fantastic job at explaining the intricacies of Android’s memory management in a previous article, which still maintains its relevancy six months later.

The way Android handles memory management is like so: rather than immediately killing off every process after its activity ended (like when you press the home button to exit an app), the process is kept in memory until the system needs to kill it to free up more memory. How does the system decide what processes to keep and what to kill? The LMK (Low Memory Killer) driver. Every process is assigned an oom_adj value ranging from -17 to 15 by the ActivityManager Service, which dynamically adjusts the oom_adj value depending on the process’ importance. Higher oom_adj values mean the process is more likely to be killed to free up memory, while lower values mean the process is less likely to be killed.

Android categorizes each process into five categories (Foreground, Visible, Service, Background, and Empty) ranging from most important to least important to keep running. Processes belonging to each category are killed off at different levels of free memory remaining (called the LMK minfree value). For example, if your device’s LMK minfree values are set to “2560,4090,6144,7168,8192” (listed as 4k pages, which can be read from /sys/module/lowmemorykiller/parameters/minfree) then your device will kill off processes defined as ‘Empty’ when your free memory falls below 32MB, processes defined as ‘Background’ when free memory is below 28MB, and Foreground apps when free memory falls below 10MB (heavens forbid!) Now, these minfree values aren’t typical on most devices these days as manufacturers love to tweak these to their liking depending on how they feel it best suits their device. But what you should take away from this brief explanation is that the more free memory you have, the less likely you’ll see critical processes being killed off.

As Mishaal mentions, the actual values vary from OEM to OEM, so you could have varying experiences with multi tasking on different phones with similar specs. Another variable in the mix is the amount of bloatware on the device. Heavily modified Android UXs like TouchWiz tend to pack in a lot of features over and above Android based on stock AOSP, and as such, require a lot more resources to be allocated to the system to function at the level the OEM wanted it to. This leaves lesser room for 3rd party apps to get cached, which in turn aggravates low memory killing.

Mostly Soft

The main difference between a device with 2GB of RAM versus a device with 3GB of RAM is that the device with 3GB of RAM should be able to cache more processes in the background without triggering the LMK driver to kill it off.

So theoretically, more RAM available at the hardware level should lead to more processes remaining cached at the OS level and a larger pool for the OEM to partake from. But more often than not, even on devices with 2GB of RAM, you see a lot more free RAM even after the system and apps have locked onto what they need. Here is the same gallery from Mishaal’s post, comparing free RAM across various devices:

Z Ultra, 2GB of RAM Nexus 5, 2GB of RAM Nexus 6, 3GB of RAM Note5, 4GB of RAM OnePlus 2, 4GB of RAM

As you can see, devices with the lightest of UI’s, like the Nexus 5 and the Nexus 6, have the largest proportion of free RAM available on the device. Even the heaviest of them all, the Samsung Galaxy Note 5 with 4GB of RAM and TouchWiz to boot, has around 1.7GB of RAM that is available for app caching. Even with such a large pool of free RAM, the Note 5 suffered from multitasking issues where the device would resort to aggressive memory handling. This was because of the OEM’s choice of LMK values: pumping in more RAM at the hardware level will not help! The fix for the Note 5 for improving multitasking actually involved tweaking these LMK values to be more multitasking friendly than Samsung’s stock settings, which is ironic for a device that focused on productivity. As such, just having more RAM will not automagically make the device more multitasking friendly.

Coming back to the gallery again, part of the free RAM displayed is already used for app process caching, but part of this remains actually idle doing nothing. Here are some screenshots from my OnePlus One showing the free RAM displayed, and then the breakup into cached RAM and idle RAM:

RAM Usage With No Active Games RAM Usage While Switching from NFS No Limits Free RAM Breakdown While Switching from NFS No Limits

Even in the small ~1 second instance that it took me to swap out of an active game and select the option to display cached processes, the system worked to trim down the actual RAM used. This happened because the game, NFS No Limits in this case, had a change in priority, moving from a Foreground process to a Background process. This was done with a view to keep the OS flowing smoothly at all times, as the RAM under active usage changed from 2.5GB to 1.9GB, while the NFS No Limits game process was cached. As the game shifted in its priority, it is now killable if the OS actually needs more free RAM. There is no user interaction required here.

The point of this example was to highlight how Android’s memory management has evolved to be more efficient in prioritizing the system and all of its processes. There’s only so many apps that will remain cached at any time: the OS ideally does not use the entire free RAM in caching processes. A part of the free RAM is let to idle. This is by design, for occasions when a process may need to scale up their RAM usage very quickly.

There is a RAM allocation cap for app processes as well, as defined by the OEM again for individual phones. According to an old discussion post by Dianne Hackborn, Android Framework Engineer, there is a limit on the Java heap where java objects will reside before garbage collection is initiated, but even that can be extended with clever use of the NDK. In simple words, this means that there was a maximum cap on the RAM that was available to any app that wanted to run on that device. For older devices, this heap was set to 24MB, but on recent devices, the size been increased thanks to the increase in RAM in devices as well as increased hardware demands. Android’s Compatibility Definition Document for Android 6.0 mentions (Section 3.7) the minimum values that these heaps should be set by the OEM. For comparison, my OnePlus One on CM12.1 boasts of a 192MB limit for normal Dalvik VM heaps and allows for as much as 512MB for apps that specify android:largeHeap=true in their application manifest. Theoretically, a single app can only use up to 512MB of RAM on my device. Beyond that, garbage collection will be initiated to keep the other necessary system processes free flowing.

Now combine the heap size limit for apps with LMK values assigned to them based on their priority and the OS’s insistence to keep a certain amount of free RAM idle, and you can imagine how Android’s multi tasking works. It’s a complex mechanism that involves a lot of variables between the hardware, the software and the app itself; fine tuned to allow even the most basic devices to function while still allowing the best of flagships to take absolute advantage of their potential, theoretically. Practically, this is not a perfect world, so neither of those happens. This means that there is no guarantee that a device with 4GB of RAM will work as equally as another with 4GB of RAM. Nor does it mean that an extra GB of RAM beyond a certain threshold will give you a directly proportionate increase in multitasking and memory handling.

The Practical & The Future

So, coming back to the original question, do you really need 6GB of RAM in your devices in early 2016? For me, the answer is no.

The majority of devices I own have 3GB of LPDDR3 RAM, and one has 4GB of RAM. And there is simply no noticeable difference in performance when it comes to multitasking. Here is a multitasking demo from my recent OnePlus X review, a device with 3GB of RAM and a close to stock Android ROM:

The device had no issues switching between 12 apps (13 if you count the active screen recorder) without having to kill any of these apps. There was no reload and no redraw, and this experience remains surprisingly consistent throughout daily usage without any reboots or manual app killing. A normal consumer simply has no need to actively switch between these many apps during practical usage!

But what if the user wishes to switch between these many games instead? Agreed, factors mentioned above would come into play to allow switching between only a few games at best. In such a condition, having more physical RAM would let the device hold more games passively in memory. But a counterpoint to this advantage is that a lot of games often do a force reload themselves upon multitasking! Their intention is to avoid cheating mechanisms from manipulating game data while the game is running, so a reload/resync/refresh forces integrity checks to come into play again. Their intention is different, but this makes a lot of games poor candidates to multitask between.

There are yet some more factors as well, that would stop you from taking advantage from all that glorious RAM. If you do find a task/several tasks combined that require all 6GB of your device’s LPDDR4 RAM, you’d have a much bigger bottleneck in the form of the mobile SoC. Granted, the Snapdragon 820 and the Helio X20 may be the flagship processors of their respective companies, but they are still mobile SoC’s. As such, they have other limitations such as heat generation, heat dissipation, thermal throttling and battery life which would make them poor choices for tasks intensive enough to use so much RAM for a prolonged period of time. In such cases, you are better off using a system that is not meant to be held in your hand; one that has more liberal limits on the heat it can generate and the power it can consume.

At the end of the day, no matter how much free RAM you have, apps will still get kicked out. That’s just how memory management works. There are still advantages to going big on RAM, like a further increase in heap size will help in powering bitmap assets on higher resolution displays, allowing us to go beyond QHD resolutions on our devices. An increased heap size as a trend across the market will lead to apps that can do aspire to do more. Unless RAM is locked off as untouchable, there will always be some or the other use for it. But considering that screens seemingly hover between 1080p and 1440p on flagships, we might see 4GB as a reasonable standard for another year or two.

11lu2g

As a conclusion, we get to answer the question: do we really need so much RAM right now? No, we don’t. For devices that have price as one of the factors that they need to keep low, 3GB or 4GB of RAM would serve them well enough. For flagships with demand from users that do not care about prices as much, it would not hurt to future proof. As a customer, just make note that you won’t be using all of that RAM just yet.

What are your thoughts on phones with 6GB of RAM? Let us know your thoughts in the comments below!



from xda-developers http://ift.tt/1qef9PG
via IFTTT

Aucun commentaire:

Enregistrer un commentaire