Low memory, apps crashing - change zram settings or add swapfile? [4.x]

Another X10II confirmation here: adding 1G swapfile is already making all the difference. I’m ready to double it, too. Flash wear issues or not, it does seem like anything is better than superslow oomkillers needing to get involved.

Relying on swap heavier does seem to make sense here, because in most cases background apps just sit there near-idle, waiting to be beckoned. That’s perfect for swap and its related performance challenges.

EDIT lol right after posting this, lipstick took all my apps away. Testing 2G swapfile now.

Why all people here doing those steps? Why don’t go full blast right away? On every SFOS device I own/owned I set my swap file to match the size of physical ram memory. I forget about out of memory issue long time ago…

Yeah you’re probably right. Maybe it’s too much concern for flash wear at the expense of daily QoL.

Indeed, from pre-32G RAM laptop days I also remember «equal to RAM» strategy, but it’s been a while since I’ve even had to think about swap :slight_smile:

If you have at least 16gb ram mobile device swap seems to be pointless. Altough it doesn’t hurt to have it.

And also how often do we see devices failing because of memory wear out? I had few n900 before, one, that never swapped anything outside of it’s internal memory it’s still alive and kickin’ today even though it has more than 13 (!) years and was used extensively for first 3-4 years.

Maybe due to planned obsolescence nowdays device will last less. But da’ hell, in 3-4 years Sony Xperia 10 III will look like something from stone age

1 Like

Couple of notes on going for 4G now

  • rootfs is limited in the default partitioning scheme, there’s only about 2.3G free

  • /home has all the space, but is LUKS encrypted: better security vs leaking anything, but how much slower to swap?

  • auto-mounting swap from /home is probably a special configuration

But I set up a 4G /home/swapfile for a test run now.

I just don’t understand why go through all that trouble? Why dont use zramctl?

devel-su

swapoff /dev/zram0

zramctl -s 6196888121 /dev/zram0

mkswap /dev/zram0
Setting up swapspace version 1, size = 5,8 GiB (6196887552 bytes)
no label, UUID=16e79d4e-8f13-4128-b5c0-32b438769ce6

swapon /dev/zram0

free -m
total        used        free      shared  buff/cache   a
vailable
Mem:           5508        3042        1067          40        1399
2889
Swap:          5910           0        5910

3 Likes

Without knowing zram details, I figured there would be a limit to how much is useful to allocate
Why would Jolla ship an underpowered configuration for so long? But indeed Drop swap for zram on Linux | Opensource.com seems to support an idea of < 8G RAM systems having 95% zram allocation :thinking:

I did initially also double zram, but it also ran out fairly quickly. Perhaps increasing both zram and adding a swapfile is the secret sauce? Going to test this next.

1 Like

It wasn’t shown on my chart, and my swap config is a bit different. I also use, aside the “build in” swap, a swap file on fast microsd card, but only slight amount (512mb) cause although card is really fast (Samsung PRO Plus V30), more swap on it causes system to “jam” somtimes. It’s just bearly noticeable but it is there. But with swap up to 512mb it doesn’t exist, or is much reduced that you cant see any difference

Both of my swap spaces have equal priorities.

Maybe this 512mb of outside swap is what you need? An additional swap on good microsd performs really well and I’ve been running with it for a long time now without any issues

(It’s not my test but it’s done on the same card)
card

Not so sure, especially if you use equal priorities. System will be writing in two different sections on th same memory. Even if you use different prios, then when system need to read something from both places it would slow down noticeably. This is not confirmed, it’s only my theory.

I didn’t do much more testing with different configs as internal swap + swap on microsd turns out to be really stable and fast configuration

1 Like

If I understand correctly, by using a zram device as swap you are trading processing power for memory (for compressing and uncompressing data that is actually swapped). Especially devices with less RAM but many cpu cores could really benefit.
My Xperia 10 II with its 4 GB of RAM is nearly unuseable when running Android apps due to OOM killer terminating random apps all the time. Using zram swap could cause a device feeling somewhat slower, but at least apps could run without being killed. Have to try that intensively…

1 Like

Jolla already ships a 1G zram configuration out of the box, so they are very aware of our RAM limitations.

AFAICT the primary strategy has really boiled down to

Today’s daily driver experience has been really good so far

  • I have 13 apps open, incl. Browser
  • Lighthouse shows 1G memory free, while 1G/7G swap is used
  • phone is still super responsive to every move I make in all apps

Swap stats probably signal “overkill”, but let’s see how this play out after a few days of heavy workweek. Stay tuned for updates.

4 Likes

Yep, I just posted about swapon -p -3 at Low memory, apps crashing - change zram settings or add swapfile? [4.x] - #52 by lkraav

3 Likes

@lkraav were you able to somehow implement your settings so this would be a default, or loaded later (during boot) system configuration at startup?

I need to manually execute few commands from terminal each time I reboot. I already asked this question few times, but nobody seems to know how to help

zram expansion is easy to persist, exactly as described in this thread.

For added swapfile on /home, I just run swapon manually, with help of Terminal history, as I aim to not reboot often.

I increased zram swap size as described in this thread. Now my 10ii does not kill applications any more.
Also fingerprint reader appears to run longer but that might be just wishful thinking.

Today’s daily driver experience has been really good so far
I have 13 apps open, incl. Browser
Lighthouse shows 1G memory free, while 1G/7G swap is used
phone is still super responsive to every move I make in all apps

After 3 weeks of daily driving additional swap on X10II, my conclusion: it is hopeless.

UX is great at first, maybe 1 day, then massively degrades as more and more key components start getting into superslow /home/swapfile. zram, even boosted, gets exhausted quickly.

Browser, as implemented, is just way too heavy of an app for 4G or less RAM. It is possible to daily drive most other apps pretty smoothly, but with every hyperlink open a massive elephant destroys the porcelain shop.

I like @jojo taking initiative with some Browser memory profiling work [SFOS Browser] Solving the browser memory issue - #41 by jojo but I think upgrading to 6G or preferrably min. 8G RAM device is the only real solution.

Isn’t that a bit much?
I mean other OS’s that supposedly are not as lightweight as sfos can run up to date full fledged browsers with a couple of GBs of ram. And they run blazing fast with no issues at all.
From what I understand is that the browser needs a lot of work and not that 6GB is not enough for a great browsing experience.

1 Like

Certainly, but I predict hardware to solve this problem significantly faster than Jolla will be able to noticeably optimize Gecko. Would love to be proven wrong. Based on the overall SFOS progress velocity, not holding my breath.

I can tell you from my 10III that 6G of ram is still not enough, but I don’t have a II to tell you the actual difference.
Based on that I believe that even with 8, that is overkill in my opinion, the experience won’t be that much different.
It is sad to open any android browser (and dealing with the whole choppy android app experience) to be able to browse without any random closes.

Angelfish + Qt Runner does the job, no Android needed.

Performance was really bad when I tried it 2 weeks ago. And I was wondering at that point, isn’t the sfos browser open source? Cause if it is, I can’t understand why people would port basically anything to SFOs instead of working on the stock browser.
Unless I didn’t understand something of course.