High memory usage

Hi,

I keep having issue with memory on manjaro xfce where it will hit 100% and then firefox (and everything else) will crash and I often end up having to reboot. Here I am at almost 80% of memory used

The thing is, when I check task manager, Firefox is using around 4GB of ram, and then everything else is insignificant. So what’s using the other ~7GB? I’m running a plex media server under it’s own user but its idle and using only 40mb of ram. Other than that, I have no clue.

I have a laptop with 32GB of ram and it sits at around 28GB available constantly and I use both of these computers the same way.

I am aware linux uses ram, but the thing is when it uses 100% ram (and it does this) everything crashes.

I don’t run a swap in order to not wear out my NVMe.

LANG=C free -h
               total        used        free      shared  buff/cache   available
Mem:            15Gi        10Gi       554Mi       666Mi       4.2Gi       3.7Gi
Swap:             0B          0B          0B

And top

Thank you

What’s supposed to happen if you use more RAM than available?
It can only crash, that’s the sole outcome in this scenario.

You could setup swap with a low (or high? I don’t know the definition) pressure. Swap is only used when necessary.

You screenshot only shows your user right? There might be others. Better use htop or top from the terminal.

Linux uses RAM for caching whenever possible, so high RAM usage is not abnormal by itself.
The kernel should free caching memory for applications when necessary. The question of your saturation is whether it fails to do so, or if there is an application grabbing all the memory…

You could check system logs for some clues: [HowTo] Find error logs
Also, please use preformatting whenever possible: [HowTo] Use preformatting in a forum post

Another option would be to install a OOM-killer daemon, which will kill the highest consuming thread if memory saturates. They also usually leave a system log for which process they kill.
https://wiki.archlinux.org/title/Improving_performance#Improving_system_responsiveness_under_low-memory_conditions

2 Likes

Hello @muchtosay :wink:

My best guess is that zswap is enabled by default and that could eat the ram, since it does not release it to disk.

Check this:

sudo dmesg | grep zswap 
sudo grep -R . /sys/kernel/debug/zswap 
2 Likes
[john@john-ms7c02 ~]$ sudo grep -R . /sys/kernel/debug/zswap
/sys/kernel/debug/zswap/same_filled_pages:0
/sys/kernel/debug/zswap/stored_pages:0
/sys/kernel/debug/zswap/pool_total_size:0
/sys/kernel/debug/zswap/duplicate_entry:0
/sys/kernel/debug/zswap/written_back_pages:0
/sys/kernel/debug/zswap/reject_compress_poor:0
/sys/kernel/debug/zswap/reject_kmemcache_fail:0
/sys/kernel/debug/zswap/reject_alloc_fail:0
/sys/kernel/debug/zswap/reject_reclaim_fail:0
/sys/kernel/debug/zswap/pool_limit_hit:0

Guessing this means it’s turned off? I did a ton of “linux tweaks” when I installed as per usual. I also didn’t partition a swap for it when I did install.

@mithrial there’s a top screenshot at the bottom of my post.

My problem seems to be that something uses 8gb of ram but that something is not listed anywhere.

I’ve noticed youtube left idle (ie youtube.com) on its homepage uses a few gb of ram doing nothing for some reason too. Maybe 16GB of ram is just not enough for firefox these days when using multiple tabs and multiple desktops?

Thanks

Yeah it is.

My default parameters:

$ sudo grep -R . /sys/module/zswap/parameters
/sys/module/zswap/parameters/same_filled_pages_enabled:Y
/sys/module/zswap/parameters/enabled:Y
/sys/module/zswap/parameters/max_pool_percent:20
/sys/module/zswap/parameters/compressor:zstd
/sys/module/zswap/parameters/zpool:z3fold
/sys/module/zswap/parameters/accept_threshold_percent:90
$ sudo grep -R . /sys/kernel/debug/zswap
/sys/kernel/debug/zswap/same_filled_pages:53
/sys/kernel/debug/zswap/stored_pages:4630
/sys/kernel/debug/zswap/pool_total_size:11759616
/sys/kernel/debug/zswap/duplicate_entry:0
/sys/kernel/debug/zswap/written_back_pages:0
/sys/kernel/debug/zswap/reject_compress_poor:0
/sys/kernel/debug/zswap/reject_kmemcache_fail:0
/sys/kernel/debug/zswap/reject_alloc_fail:0
/sys/kernel/debug/zswap/reject_reclaim_fail:0
/sys/kernel/debug/zswap/pool_limit_hit:0

I don’t think so. I am using gnome3 here and only firefox with 25 tabs plus extensions.

$ LANG=C free -h 
               total        used        free      shared  buff/cache   available
Mem:           7.7Gi       3.5Gi       1.5Gi       174Mi       2.8Gi       3.8Gi
Swap:          255Mi        18Mi       237Mi

So it is about 2.5GB just for Firefox. In anyway… I highly recommend a small swap file at least. I use systemd-swap to manage that dynamically. Also run systemd-oomd so that it kills the application when it tries to swap a lot.

Won’t a swap kill my NVMe over time due to writes?

On reddit I found a lot of people saying 16GB isn’t enough for FF or Chrome especially. I think I will probably upgrade to that.

I have 6 FF extensions and currently I have around 120 tabs open (12 workspaces, ~10 tabs per workspace. I leave my computer on 24/7 so tend to move stuff to other workspaces.

in fact a nvme has only a limited write-cycle-capacity. RAM isn’t that expensive anymore and the far way better solution is to expand the RAM.

1 Like

It may happen today but I have yet to wear out an nvme stick or an ssd drive.I have several that have lasted for several years and had many different systems installed and wiped out on them and there still working.Swap isn’t going to wear out the drive.Having 12 tabs and 12 work spaces you can see why the memory is high.

Your NVME will be fine. Check on the manufacturer website the specs, but the amount you would have to write on it to wear it is astronomical. Your Firefox cache writing is probably wearing more your NVME than what a SWAP file would do in my opinion.

That’s non sense, even 8GB is plenty. On the other hand, your use of Firefox is not normal, having 100+ tabs is huge.

1 Like

On a system with only 12GB of RAM, and a small swap file (which almost never gets used), I do not face the issues you are describing. This is on KDE, nonetheless, which is supposed to be more resource-hungry than Xfce.

Something tells me Firefox is the culprit, with a mix-and-match of addons plus 100+ tabs open: firefox process using 4 GB for RSS, just idling on a website?


Using swap can only help so much, but in the end it’s a last-ditch effort to spare yourself from crashing or freezing.

To be honest, I don’t think I’ve ever used swap for a long time now, ever since RAM pricing and capacities have comfortably exceeded typical application demands.


As others have said, doubling your RAM will do you worlds more benefit than increasing the swap size. In fact, you can double your RAM and then later decide to increase swap if desired or needed.

1 Like

Dumb question: why such use?

1 Like

I have ADHD and so I’m constantly flitting from thing to thing. Instead of saving bookmarks and losing my place on the page I normally just move the entire browser window to another workspace.

It seems to be Youtube videos that cause the ram loss, even if not loaded (ie, have not played them), but other sites like old.reddit.com or facebook do the same thing.

On my laptop with 32GB I never get these issues, so maybe now is a good time to upgrade my computer.

Increasing the memory would obviously help. You could also reduce the number of open windows, thus not having to invest into upgrading, though i do suppose working on your disorder would be easier said than done… :thinking:

You could take a look at addons for session managing. This could replace keeping open windows, though a downside would be that position in a page is usually not kept.
https://addons.mozilla.org/fr/firefox/search/?q=session%20manager


If i may suggest a “simple” exercise: try working with only the number of workspaces you currently have. Whenever all workspaces are occupied, you must free one first: check what’s on it, complete what you’ve started on it… And then, from time to time (once a week/month?), remove a free workspace altogether.
You don’t necessarily need to go down to a single workspace, only reducing the number in order to find a balance between your disorder and your system capabilities.

Cheers!
:kissing_heart:

Thanks. These are all helpful but don’t really address the problem especially when you see Windows 10/11 users with 4-20x the open tabs and no issue. I have ordered some more ram.

hm… :thinking: and you explicitly disabled the swapfile on windows? A swapfile is enabled on windows by default.

Your comparison is completely irrelevant. You say you have 4 to 20 times the number of tab on Windows compared to Linux? Are you insane?

First you can’t compare opening 400 tabs of a text file to 100 tabs of Youtube video for example. What is loaded in a tab is what matters. And from my experience on Windows or Linux it is fairly comparable in term of resources usage.

PS: also what megavolt said.

//EDIT: for the sake of it, I went to Windows, opened three tab of a specific website, took 716MB, rebooted to Linux, same thing, took 719MB. On both systems it could go up and down a little bit without doing anything. Fairly comparable. I don’t believe at all your affirmation about the 4 to 20 times more tabs opens on Windows (obviously for the exact same websites opened). That is :chestnut:

Based on your nvme TBW, You can easily calculate the lifespan of your SSD. no it wont kill your ssd… it will last atleast the warranty period… that would be 5 years as per standard warranty goes

I disable swap on all my systems, for performance and to protect the SSD.

So you compared my statement of having hunreds of open tabs by your own experiment of opening…three tabs. And conclude this means both OS’ can handle memory just fine?

Why are Linux people like this? Why do you refuse to believe that Linux can have ANY problems?

I literally hit the 16GB of ram limit every day. Though it’s hard to see what’s using it, task manager will say a game is using 4GB and Firefox is using 6GB and all the processes add up to around 1GB but overall ram usage is somehow 16GB and then firefox will crash due to running out of ram. It’s like something, that doesn’t show up in htop, is using 10GB of ram.

Still waiting for the 32GB kit to show up from the US.