How to clear zRAM swap memory without reboot?

It occured to me that the zRAM swap memory easily is fully used and no free space left even if all apps are closed and Android Suppord is stopped. I suppose that closing all apps should automatically free some zRAM swap meors space. But that appently is not the case.

Only a reboot helps.

Therefore my question: is there a way to clear the zRAM memory without rebooting the device?

I have read this topic , but that is about increasig swap memory size, not clearing the swap memory.

1 Like

what are you trying to archive? linux systems typically keep the ram as full as possible in case the data can be reused later. There is no advantage of unused ram, as caches are just dropped when you need it.

I am not saying there might not be a memory leak or other issue. just asking if you are aware, that memory usage is complicated.

1 Like

My problem were permanetly crashing apps (even if only one app was open and Android Support off) due to lack of memory. A reboot helped and I guessed (maybe wrongly) that this was due to a lot more free memory (as seen with lighthouse)

There’s some /proc/sys/ tunable that will release file caches, but that will not solve anything ( its basically only useful for IO benchmarks).

What you can check is /tmp, that’s in RAM as well, and it should not fill up. If it does, find what is causing it.

1 Like

if i remember correctly, there is currently a bug with how memory is calculated. kerry wrote about it, i think.

In that case it might actually help, because it fixes the buggy calculations

@JoOppen When I want to reduce RAM usage I have the following shell script:

sync ; sync ; sync ; 
echo 3 > /proc/sys/vm/drop_caches;

3 sync to write everything in cache to the disk and then you drop the caches. I just tried it, it seemed to work.

I also tried to disable swap by using:

swapoff -a

It didn’t seem to work. As I have noticed in other linux machines, swapoff “moves” data from the swap partition to the ram and then deactivates it.

1 Like

It is overkill for the original question to trigger all the filesystem oriented flushes (via sync, for which issuing it once should be fully sufficient, and echoing 3 to drop_caches).

To flush the page cache (“memory” / RAM) only, execute
echo 1 > /proc/sys/vm/drop_caches

2 Likes

I’d be interested in knowing what the ‘only one app’ that was open was when ‘Android Support’ was off. And which device do you have with what amount of RAM?

The device is Xperia 10 ii with SFOS 4.1.0.15 The single apps that get killed are the native brower or Fernschreiber or the native email client (These are the apps that I use the most). Therefore I cannot attribute the this to a single app.

I have to admit that I have many open tabs in the browser but the browser is mostly closed and email client and Fernschreiber are affected.

I wonder whether media files in telegram could have caused the problem initially.

I would guess you mean 4.3.0.15? I haven’t had a chance to update yet but I’ll make a note of, for instance, browser RAM usage before and after and see if it has something to do with 4.3.0.15. Did you seen anything like this with 4.3.0.12?

1 Like

Ok. No real discrepency between 4.3.0.12 and 4.3.0.15. Clearly the browser uses much more memory than anything else:)

Have you tried using Crest or some other process tool to watch ram usage? With 5 / 6 open Tabs I always see about 700MB+ Ram being used. Just adding a Google tab (Google finance currency) adds 80MB of RAM usage. CPU remains fairly stable at 30%. I stopped poking at about 10 Tabs and around 900MB of RAM usage. Still, lots of RAM left. Hmmm.

For comparison, my Moremahjong app, which is also a Webview based app, consumes almost 300MB (which is also criminal). That’s bascially a one tab web app with SVG javascript processing. Most Apps hang around at 90-140MB

1 Like

You are right: the 10 ii is on 4.3.0.15.
Since the reboot my 10 ii behaves like yours (again). When dhecking memory usage with lighthouse, no app was extensive memory. However, closing apps did not free sufficient memory
I did not try crest yet
For months, everything was fine - I don’t know what went wromg lately
Now, I can easily open 12 apps simultanously without any crash (including memory-hungry browser)
Maybe I will never find out because the cause of the problem disappeared with the reboot.

Thank you for your hints!

A great addition would be a feature in SFOS utilities to flush zRAM swap memory.

1 Like