Header Ads Widget

Responsive Advertisement

What is Virtual RAM in Android- Explained In-Depth

What is Virtual RAM in Android- Explained In-Depth

If you've been following the recent smartphone launches you know that Virtual RAM is one of the most highlighted features in all of those launches whether it's called Virtual RAM or extended RAM or dynamic RAM expansion or whatever marketing term that RAM's use the idea added score is the same to give more RAM to your user. Or is it or is it just some marketing jargon that makes actually zero sense?

Well, let me find an answer to that. I'm gonna deep dive into how memory management in Android actually works. What this Virtual RAM really is and whether as a consumer you should be bothered or not. Now, this article is going to be a little bit techy and geeky but I'll try and simplify things as much as I can.


How Android currently makes use of its memory management techniques?

Without understanding the basic fundamentals, understanding Virtual RAM will kind of be a little difficult. So at its core, Android makes use of Paging and memory mapping instead of using Swapping like Linux does. Now we get to swapping and what Linux actually uses in a bit. But Let's stick to Android for now.


So now within Android, you have three types of memory.
  1. RAM
  2. zRAM
  3. Storage

Storage is basically your UFS storage or your eMMC storage. Basically, the internal storage that we all have, RAM is your DDR RAM. I mean we all know what RAM is. And let me just illustrate for you guys to understand that DDR RAM is like way faster than any sort of storage out there. Like seriously just remember that RAM is any day faster than whatever kind of storage that you put out. Even an SSD is not as fast as a proper DDR RAM. So keep that in mind. Lastly, we have zRAM.


What is zRAM?

Well, basically consider zRAM to be a partition on your RAM. So the idea behind zRAM is that low priority data that is currently running on the RAM. Well, the system does not actively needed. So what it does is that it comes presses it and then stores it in a different partition which is the zRAM. Now obviously there is a give and take involved in terms of CPU processing because you have to constantly compress the data and then actively decompress it. But that process is any day faster than accessing your data off the storage.


Ok so now I said that Android makes use of Paging right? Well how it works is that memory?

Basically, your RAM is divided into pages where each page is typically 4KB. Basically, consider Paging just to be a part of your memory where each part is of 4KB. Now all of these pages whether they are being actively used by an application or they are free respectively show where how much of your RAM is being actively used or how much RAM is free respectively. Obviously. Now the way that Android manages its memory is that it basically makes more free memory.


How does it make more free memory?

Well, it just actively shifts those used pages and the data on those use pages to your storage. So how does that happen? So Android makes use of a Kernal Swap Demon or Kswapd that actively switches that. And this is defined because pages can broadly be categorized into two categories Clean pages or dirty Pages. Now clean pages are something that have an exact unmodified copy on your storage. So basically if you need free memory then the copy of your clean page can be removed from your RAM because there's already a copy unmodified copy of it on your storage.

On the other hand, dirty pages are basically that are actively being used in the ramp that are dynamically changing. So there copy on the storage is a modified copy that who has a little bit too technical. Right. Well, let me try and illustrate with a real-world example. So Let's say you're multitasking on your phone and you have a lot of apps open on your phone. So for instance now Let's say you open Twitter and then you blouse your feed and then switch to something else.

So not Twitter is there in your RAM but it's not actively refreshing. What I mean by that is that what you take at notifications but your timeline is still not actively refreshing. And then when you switch back to Twitter the first thing that you'll see is that the timeline in its exact state where you left it after which the app will realize OK now it's being actively used following which the app will refresh its timeline.

The same thing happens whether you're using Facebook or read it. As a user you may feel that OK my app is still running in the background when it's actually not is just on your storage but when you just launch it, all these relaunches in that same state exactly how Hibernation works. So Yeah that was clean Pages.


Now for Dirty Pages.

Let's say you have Spotify or any of the music players running in the background. So what do you do in that scenario? Well, it cannot be shifted to your storage because it dynamically running at best for the system can do. If it requires a lot of free space then what it will do is that it compresses Spotify and then shift it to zRAM because it cannot shift it to storage that is dirty Pages. So now that you understand how Android manages its memory Let's move on to the other side of the spectrum. Or not exactly the other side of the spectrum but basically how every other Linux distro works which is that by using a swap partition.


How Linux does its memory management techniques?

So a Swap partition is basically an extra space allocated onto your physical storage partition space. A portion of that storage is being used as a swap partition. So the way Linux does is that whatever app you're running, it will try and force it to run on the RAM till the point where the ramp is fully used. Now when the RAM is fully used and now the system says okay now we need to launch another app and now we need more free RAM at that point of time. What Linus does is that it moves an entire process to the swap partition.

So the difference between Paging in Android and Swapping in Linux any Linux distro is that pages, they shift pages in a sense that part of memory. Whereas in Swapping an entire process is shifted to the storage. Now is that what all these companies are doing? Well pretty much. Yeah. Basically what they're doing is that they're creating a swap partition and they are just shifting data all around.


Virtual RAM in Android

Vivo sent us in their relays while launching the X60 series which makes use of the Virtual Ram feature. Instead of distributing small amounts of memory data, it uses processes as a unit to accurately identify processes which are of low importance. I do not affect the user experience among those occupy a large amount of memory and exchange these processes with external storage space so as to greatly reduce the running memory occupied by a single run. Thus the original DDR storage space of a fixed capacity comes about the running of more apps. Basically swap.

Now before I talk about whether this worthful RAM is good or not for you a lot of you guys might be saying that Hey but my phone already has swap. If I install an app like Disk info for RAM truth they'll say that okay. This month Swap memory is allocated which is kind of true but there's a different story to it.


Swap or zRAM

See Here's a thing the only difference in the swap that you see in those apps is actually the zRAM. In fact, if you actually open Ram Truth and tap on the Swap partition it will show you that unless you're using a custom kernel that makes use of a modified Swap partition the swap partition store it space that you're seeing right here is technically just zRAM.


Linux has already been using Swap for ever since that was invented but why has Android not been using it?

And why has it taken the company so long to well get to the stage? I mean they're not doing anything new or extraordinary. He's just bringing a partition to Android and custom prom users out there. They know that swap partitions could have been created back in also back in those days 2010 or 2011. But Yeah it comes at a cost and that is what defines the pros and cons of this so-called Virtual RAM or swap.


Pros

Well, the positive here is that you get more RAM place available when you actually need it. For instance when you are recording high res videos like 4K, or 8K footage you do not want your background to close. That is where virtual RAM comes in handy. Whether you're gaming that is where extended RAM comes in sort of handy. So Yeah that's good. So far so good.


Cons

See all of this works fine on traditional hard. We like the top of hard disks but flash memory like SSDs or your UFA storage which is there on your phone. They have a limited lifespan of certain reads and writes. Like Seriously SSDs have a limited defined number of reads and writes that they can support after which they will just start forgetting data. That is just how SSDs basically any flash memory works.

Like seriously Android developers knew this already which is why they already mentioned it on their developer page. So on android storage isn't used for swap space like it is on other Linux implementations since frequent writing can cause wear on this memory and shorten the life of the storage medium.

Now, if you need a modern refresher of it just take a look at all of the complaints around the new apple M1 MacBook air where all the users have been complaining about the extensive amount of swap memory that is being used and they're all complaining that yes it'll just shorten their lifespan of their SSDs.

Now I'll admit that with modern technologies and new advancements SSDs have a much higher lifespan. No denying that is true. But there's also no running from the fact that even after that swap will eventually affect the lifespan of your storage. so long story short.


Is virtual ram good?

Well. if you're into high-res video recordings like 4K or 8K footage of very long videos then yeah. If you're into gaming I think every OEM screen out there has their own custom gaming world which should suffice for that job so you don't really need extended ram. For everyone else I mean, this is best to keep the feature turned off because it's something that you won't even be using as much and regardless it will be deteriorating your storage's lifespan and nobody wants that.

Well, that was it. I know this article got a little bit too techy but I'm sorry I just wanted to ensure that all of you guys got hold of the real big picture. I don't blame brands for doing what they're doing I mean it's still good marketing and it's still a new feature. It's just that I feel they should have been a little clearer here that using virtual ram will sort of effect the lifespan of your device as well.

Post a Comment

0 Comments

class='back-top' title='Back to Top'/>