(INFO)What is zram and how does it work???

Status
Not open for further replies.
Search This thread

-CALIBAN666-

Senior Member
have found a lil more about zram,i hope it helps anyone!!!!:)

zRam(Zero Capacitor Ram)
------------------------
zRam is an experimental(staging)module of the Linux kernel.It was previously called"compcache".zRam increases performance by avoiding paging on disk and instead uses a compressed block device in RAM in which paging takes place until it is necessary to use the swap space on the hard disk drive.Since using RAM is faster than using disks,zRam allows Linux to make more use of RAM when swapping/paging is required,especially on older computers with less RAM installed.

To make it simple,zRam allows to virtually increase the amount of RAM your device has by using the Swap spaces in your device memory.This is mostly profitable for "LOW-END DEVICES" that come with "FEW RAM" (512mb generally).
-------------------- -----------
GREEEEEEEETZ :)
 
  • Like
Reactions: n3m3sis

TimidRat

Senior Member
Jun 12, 2010
409
50
Las Vegas
I mean absolutely no offense and thanks for helping so many others, but after reaing that i'm 1,000 times more confused.
 

casaque89

Senior Member
Oct 23, 2012
82
4
Heredia
www.facebook.com
Im sorry guys I've read all the thread... But I'm still confuse.

I have a Galaxy S3 with Googy Kernel, I have installed the stweaks app and it gives me the chance to set the ZRAM at 200 mb with 80-90% swappiness... Is this worth for me? Would I get more free RAM memory? Or would I have better performance playing games?

Thanks in advance

:what:

Sent from my GT-I9300 using Tapatalk 4
 

orgert

Senior Member
Nov 17, 2012
728
409
Im sorry guys I've read all the thread... But I'm still confuse.

I have a Galaxy S3 with Googy Kernel, I have installed the stweaks app and it gives me the chance to set the ZRAM at 200 mb with 80-90% swappiness... Is this worth for me? Would I get more free RAM memory? Or would I have better performance playing games?

Thanks in advance

:what:

Sent from my GT-I9300 using Tapatalk 4

im also using googy max 1.7.9 on cm 10.2 , and in my experience , zram actually help on multitasking, i ve set it on defoult, on 400mb, like when i play real racing 3 , and have to write a sms , i close the game , and than when i go back, it starts where i left it, without zram it will close in less than 30 seconds. but i ve noticed more battery draind and my phone getting hotter than usual ,so im not using it anymore. but hey , this is just me , u have to try it out to see for your self
cheers :)
 

gamervishal

Member
Mar 21, 2014
28
5
More confused

Just a question,
I am currently on Stock running Jarvis Kernel on my Galaxy Y. The kernel says it supports zRAM, so how can i enable it? :confused:
 

-CALIBAN666-

Senior Member
try to create this as init.d script with rootexplorer etc and set permission like other init.d ones.


#!/system/bin/sh
sysctl -w vm.swappiness=90
echo '1' > /sys/block/zram0/reset
echo $((1024*1024*64)) > /sys/block/zram0/disksize
mkswap /dev/block/zram0
swapon /dev/block/zram0

dont forget backup,not sure it works or not
 
  • Like
Reactions: Justasmig

karnal.girish

Senior Member
Apr 30, 2013
92
9
can the zram be programed if so how

this is very informative thank you.. i have a doubt... can we redirect the zram to a sd card partitioned space, or it wont help if as it utilizes the same space as before... i am using iberry auxus note 5.5... it has 2gb ram so there is not need of zram for me i guess but still if possible would help to speed it up a little
 

totiadrenalin

Senior Member
May 13, 2010
169
279
Sveti Nikole
Is enabling the ZRAM is the correct step to gain performance?!!

If you really like to speed up your android device (iberry auxus note 5.5) that have 2gb of ram, then activating the zram is the first wrong thing you could do!
Anyway to activate zram your kernel need to support it, and except if you are running some custom rom on your device with enabled zram functionality, the Manufacture of your device will never let you do this on it by default!
But even if you do activate the Z-Ram ( aka compcache - Compressed cache) then you will loose some of the CPU's processing power for compressing and decompressing the inactive applications into a separated memory block in the devices Ram memory. Also this lead to less idle state of your device, because the CPU will wake up pretty often trying to compress and decompress the needed data, so this will leed to more battery consuming. And if you like to get some gaming performance you will have to activate the GPU rendering, which will also lead to more battery consuming, and over all you will loose much more than you could get from the Zram!

Anyway for those devices with 512 mb of ram or even less, my advice is to try to setup the OOM minfree parameters (Out of memory killer - The task manager integrated in the Android kernel) values, so less inactive cached apps will occupy the ram, in other words more free ram for the foreground, Visible and secondary Server(Services) applications.
The main disadvantage: the more aggressive the minfree values you set, less multitasking you'l get.
Also you could play around with the sysctl command (system control).

Finale conclusion: If ZRam was necessary for your device's performances, than it would have been pre-activated by default!
 
Last edited:
  • Like
Reactions: EPLENA and #Henkate
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 120
    I think its better to Post this here,when its not better,than sorry!!!
    -----------------------------------------------------------------
    Once a brief statement for those who are not traveling so long in the Android scene:
    ZRAM = ramzswap = Compcache

    In order to explain more precisely ZRAM first need other terms are more clearly defined:
    Swap can be compared with the swap file on Windows. If the memory (RAM) to complete the PC the data that are being used not actively outsource (eg background applications) so as to re-evacuate RAM free. To this data is written to a hard disk. If required, this data is then read back from there easily. Even the fastest SSD is slower than the RAM. On Android, there is no swap!

    In ZRAM unnecessary storage resources are compressed and then moved to a reserved area in the fixed RAM (ZRAM). So a kind of swap in memory.
    This Ram is more free because the data then only about 1/4 of the former storage requirements have. However, the CPU has to work in more because they compress the data has (or unpack again when they are needed). The advantage clearly lies in the speed. Since the swap partition in RAM is much faster than this is a swap partition on a hard drive.

    In itself a great thing. But Android does not have a swap partition, and therefore brings Android ZRAM under no performance gain as would be the case with a normal PC.

    In normal PC would look like this:
    Swap = swap file (on disk) -> Slow
    ZRAM (swap in RAM) -> Faster than swap
    RAM -> Quick

    With Android, there is no swap partition, and therefore brings ZRAM also no performance boost.
    The only thing that brings ZRAM is "more" RAM. Compressed by the "enlarged" so to speak of the available memory. That's on devices with little RAM (<256MB) also pretty useful. The S2 has 1GB but the rich, and more than. There must not be artificially pushed up to 1.5 GB.

    After you activate the ZRAM also has 2 disadvantages. The encoding and decoding using CPU time, which in turn has higher power consumption.

    Roughly one can say (For devices with more than 512MB RAM):
    Without ZRAM: + CPU Performance | + Battery | RAM
    With ZRAM: CPU Performance |-Battery | + RAM

    For devices with too little RAM so it makes perfect sense. But who shoots the S2 already be fully complete RAM and then still need more?

    Check whether you can ZRAM runs in the terminal with
    free or cat / proc / meminfo

    I hope it helps to understand zRam!!!!:eek:
    18
    I think its better to Post this here,when its not better,than sorry!!!
    -----------------------------------------------------------------
    ...
    With Android, there is no swap partition, and therefore brings ZRAM also no performance boost.
    The only thing that brings ZRAM is "more" RAM. Compressed by the "enlarged" so to speak of the available memory. That's on devices with little RAM (<256MB) also pretty useful. The S2 has 1GB but the rich, and more than. There must not be artificially pushed up to 1.5 GB.

    After you activate the ZRAM also has 2 disadvantages. The encoding and decoding using CPU time, which in turn has higher power consumption.

    Roughly one can say (For devices with more than 512MB RAM):
    Without ZRAM: + CPU Performance | + Battery | RAM
    With ZRAM: CPU Performance |-Battery | + RAM

    For devices with too little RAM so it makes perfect sense. But who shoots the S2 already be fully complete RAM and then still need more?

    Check whether you can ZRAM runs in the terminal with
    free or cat / proc / meminfo

    I hope it helps to understand zRam!!!!:eek:

    Well even though many thanked your post, your statement is wrong in several regards. You say that Android has no swap partition (which is true) and so zram would not bring a performance boost (which is partly wrong). It will also not give you more RAM (just check any program that reports available RAM on the device). It will actually give you LESS free usable RAM, but supply an additional type of memory space (the swap) instead. This Linux "Swap" space is usually not activated with Android on top of it but there is no reason not to try out.

    Despite its name, ZRAM has little to with RAM (except that it uses it). ZRAM is a block device in RAM which can be used only for Swap purposes. It acts as a swapfile however is not on disk but in RAM where the blocks are compressed - so not using the size they would use on uncompressed devices - like a disk.

    For its use just look at the sequence of actions to activate it (from my device):
    Code:
    #!/system/bin/sh
    sysctl -w vm.swappiness=100
    echo '1' > /sys/block/zram0/reset
    echo $((64*1024*1024)) > /sys/block/zram0/disksize
    mkswap /dev/block/zram0
    swapon /dev/block/zram0
    1. set swappiness to max value (this makes sure it also well used) - you may vary here
    2. you must create a block device in \dev\block\zram0
    3. you activate swap on that device
    So you see that actually the normal Linux SWAP is used, but it is on that special ZRAM device. Contrary to assumptions read, the amount of swap space reserved is the offered space to the system (in my case 64MB), but not the RAM eaten away from the system. That is the good part of the story - in my observation the amount of RAM eaten is just 1/3 of the swap space offered. You get the used size be accessing \sys\block\zram0\mem_used_total.

    Well and "performance boost" is not what you may expect here. The swap space can help to keep applications "active" for Android instead of killing them for low memory. So if you switch back from a large gameplay eating all your RAM the Launcher may just swap back from ZRAM which is much faster than having it restart and read all the apps icons again. Same when switching to other apps that were active before.

    Mind that the already sophisticated Android management (with priority levels of RAM use for applications) gets another complexity below that on the Linux layer with Linux SWAP. On Linux level the "swappiness" and on Android the memory levels for the memory manager priorities may need to be aligned with a clever strategy (which I don' have). I am too little expert on memory management but I noticed that Go Launcher much less reloads with ZRAM than without.

    Edit 20121214: I have de-activated swap in the meantime for me. Things are getting too laggy for me in daily use, no matter which swappiness selected. So I pay the price that sometime I could have Go launcher not reload with much more frequently waiting for any other UI action to complete. This is not even predictable well (because of not well linked memory management is my guess) and so I chose the lesser evil for my use.

    Please also consult other sources as your device may have different paths to read data from. The architecture of Linux/Android is however surely the same.
    3
    no its very good for devices with less ram like 289mb and we have less ram,so its useless for higher ram devices with 800-1000,but that can u read in this guide;)
    2
    Is enabling the ZRAM is the correct step to gain performance?!!

    If you really like to speed up your android device (iberry auxus note 5.5) that have 2gb of ram, then activating the zram is the first wrong thing you could do!
    Anyway to activate zram your kernel need to support it, and except if you are running some custom rom on your device with enabled zram functionality, the Manufacture of your device will never let you do this on it by default!
    But even if you do activate the Z-Ram ( aka compcache - Compressed cache) then you will loose some of the CPU's processing power for compressing and decompressing the inactive applications into a separated memory block in the devices Ram memory. Also this lead to less idle state of your device, because the CPU will wake up pretty often trying to compress and decompress the needed data, so this will leed to more battery consuming. And if you like to get some gaming performance you will have to activate the GPU rendering, which will also lead to more battery consuming, and over all you will loose much more than you could get from the Zram!

    Anyway for those devices with 512 mb of ram or even less, my advice is to try to setup the OOM minfree parameters (Out of memory killer - The task manager integrated in the Android kernel) values, so less inactive cached apps will occupy the ram, in other words more free ram for the foreground, Visible and secondary Server(Services) applications.
    The main disadvantage: the more aggressive the minfree values you set, less multitasking you'l get.
    Also you could play around with the sysctl command (system control).

    Finale conclusion: If ZRam was necessary for your device's performances, than it would have been pre-activated by default!
    2
    Sorry for too many questions mate - am the noobest guy here on xda that is why :(

    no problem bro,thats the reason why i open this thread.and hey im noob too :eek: