[Galaxy Note 4 Android Development (Snapdragon)] Senthil360:
Multitasking and VM Explained​

Lately we have had a lot of questions/complaints regarding phone becoming unresponsive and poor in multitasking, after a few hours and so on. I'll try to provide an explanation and clarity regarding these things from what myself and my team have known and experienced.

Note :This discussion is only for TOUCHWIZ, the case of AOSP/CM based ROMS are completely different

First of all let's see how the influence of VM is in Android, RAM is used majorly for buffers, Applications and also caching our read-write operations.

What happens when this RAM gets scarce? Why sometimes there are huge pause and delays? Let's find out.

Let's say you do a particular operation in a Linux based system, after you finish the operation, the kernel can do two things, it can kill/end the task or keep it in the RAM as cache.. What it does is the interesting thing.. It THINKS that you will perform the same operation again and instead of dropping the cache it KEEPS it. Perhaps many of you would have already known this.

But Android is a Linux based OS and in exact same way we can adjust the values, that might help us to some extent.

VM Dirty_background_ratio : This decides how much cache your RAM keeps as a percentage value, suppose if this value is set as 10 it denotes that 270 MB of cache out of 2.7 GB of our Note 4's system memory (RAM)

*Default Nameless value is 20

VM Dirty_ratio : This is the maximum amount of cache your RAM can keep before all of it gets flushed.

Default Nameless value is 40

VM Dirty_writeback_centisecs : This is the time denoted in centisecs, this runs continuously in the background and at the end of for every single cycle all of the cache gets flushed.

*Yes it does the same thing as dirty ratio and it is present in system as safeguard mechanism

Default Nameless value is 2000 = (20 seconds)

##At some point if the system finds that the cache is too much it gets confused for a short time (the pause and delay) and it decides to write the cache synchronously (say in foreground) and not asynchronously (background) like it did before, this decision takes some time too.

VM Swappiness : In any virtual systems swap is not good and hence why we set it to 0, (Zswap, zram are also obsolete for practical usage with any 1.5 GB + DEVICES, thanks to [MENTION=5514152]Paget96[/MENTION])

Next up is very important one,

VM Vfs Cache_Pressure : Setting a value below 100 for this favors the system to leave behind more "dentry and inode" (file system caches) which is far more important than others such as Block and IO cache, because it has a direct influence on speed of tasks you perform.

BUT the downside if this cache keeps growing your system might start getting laggy ..

For my usage (I clear RAM time to time and don't multi-task with more than 4 heavy apps) I have set a value of 20 but its up to you to decide this value

There are many other things like overcommit ratio, minfree kbytes, etc etc which you can leave at default of our Rom.

TouchWiz is a OS which has extra heavy RAM usage by default, and I think it is pretty clear for everyone now not just the apps use the memory but a lot of other things too. Not being able to multitask with 6 apps or system getting unresponsive is not fault of any TW based custom ROMS, its how TouchWiz is and no point complaining about it, we have tried our best with NL to eradicate these issues.

We may not be the Best Team or we might not have given you the best things so far, but one thing I would like to say is WE HAVE TRIED AND WILL ALWAYS TRY not to compromise in trying to give you the Best ROM, Kernel and Tweaks. I would like to take this moment to thank each and everyone of you guys for being with us making this wonderful journey possible for Team Nameless

Have a good day,patiently waiting for MM :D