Follow

One thing I fight with on Linux is RAM and SWAP that is being used in 10ths of GBs, yet tools like htop don't show any processes using that much memory (even when run as super user). I know that disk reads are cached, this is not the problem here though. What is eating up my RAM? Why I cannot identify processes that allocated this memory? How can I reclaim it without rebooting my system?
Help!

· · Web · 9 · 2 · 4

@unfa there is a thing called swappiness that swaps things to disk that Linux think are not needed in active memory.

linuxhint.com/understanding_vm

@unfa Pressing H in htop should group all threads together, may make it easier to view more processes per screen and find something. All I can say at the moment...

@unfa The RES(ident) column would probably be what to look at to identify memory usage by process. So if you group the threads like has been suggested and then sort by RES then probably something would stick out.

@espen @unfa
this ^
plus if you're on systemd, you can set DefaultMemoryAccounting=yes
in /etc/systemd/system.conf
(requires reboot)

and see RAM usage grouped by user / systemd service using systemd-cgtop

@unfa not a bug, but a feature! processes that were open but closed now stay in memory, if you're not utilizing it for anything else

@gangrenouspenis Hmm. Why do some processes I kill free up memory instantly and some(times they) don't?

@unfa Also, I see so many lines of 1% mem usage that I wonder if they together maybe add up to the total you are seeing there

@unfa
I use free - m command to see if current ram usage is less than available space. If this is true you can release swap without rebooting with swapoff command unix.stackexchange.com/questio

@unfa
No swap, no problem with swap.
with 32G of RAM, is it necessary to enable swap ?
Use github.com/raboof/realtimeconf

@jujudusud If you're editing heavy video - yeah. It's needed.

@unfa
did you look at how to set the swapiness parameter ?
With something like :
sudo sysctl vm.swappiness=10

@jujudusud Oh sure - Hmm. It's set to 60. I think I've been changing that to 10 some time ago, but if memory pages are freed then this shouldn't have any effect. Seems like they are not freed however.

@unfa I have the same problem, I have browser and couple of terminal emulators opened and the RAM usage is about 11 GB out of my 16 GB's. I've used a C program to allocate memory and it went to 5 GB allocated before it was killed, after that still 10.5 GB used so it's not a disk cache problem? I'm using Manjaro KDE. (I also noticed that after I wake up my PC from sleep the ram usage grows by ~3 GB and it doesn't get freed no matter what I do) The htop also doesn't show anything suspicious.

@Ernest1337 @unfa
I always think that linux never unallocate ram as long as it's not needed.
So i end up monitoring swapin/swapoff (the amount of memory going to/from swap) to monitor memory issues.
The command free can show you what is in the cache, memory used as cache (data) can be reused for anything once you stop working on it.
Let's say you open a doc, it goes on ram and will stay in cache data even when you close it. It will be delete if needed

@oldsysops @unfa
But the problem is, it doesn't get unallocated even if it's needed!

Example (I have 16GB of ram):
I have 10GB ram used (htop) and 7.1GB is in buff/cache (free -h).
Then I run a VM in Virtualbox. The system get's very unresponsive (about 99.5% ram usage). When I kill the VM, buff/cache is still ~7GB. Can you explain that?

@oldsysops @unfa VM has 4GB assigned to it. Either way my PC should handle the workflow I was running then, this is: Brave browser + couple of terminal emulators (konsole) + file manager and the VM. The RAM usage shouldn't be as high as 10GB in the first place.

@oldsysops @unfa That surely isn't a normal behaviour. I closed every app except terminal, disabled the swap, dropped the caches (/proc/sys/vm/drop_caches), ran the memory allocation program which was killed at 5800MB and took this screenshot. Memory usage at 10GB and no way of reclaming it. HELP

@Ernest1337 @oldsysops Stuff like this happens to me a lot. But not always. It has to be a bug, maybe in the Kernel?

@unfa @oldsysops If that's a bug in the kernel, wouldn't it be a huge deal in the data centers? I wonder if that's something specific to Manjaro KDE or some application we are running.

@Ernest1337 @oldsysops I've been seeing stuff like this happening in the past decade. Maybe it's a bug in X.org? I should try Wayland.

@unfa @oldsysops Yeah, X.org makes sense, but why is it not known? Maybe it's hardware (driver) specific?

@Ernest1337 @unfa the htop screen you show put plasmashell in top clndumer of memory.
Use this command :
ps aux |sort -nk4| tail -20
To find the 20 process which use most of the memory.
I don't know #KDE well but it's seems odd that ot use so much memory.

@oldsysops @unfa But it doesn't use that much memory. 3% of my 16GB is only 480MB. Correct me if i'm wrong. Maybe I don't understand something.

@oldsysops @unfa Now when I see the screenshot I sent earlier, I had very high shared memory usage. Now on a different session I have only 500MB in shared memory. Interesting...

@Ernest1337 @unfa I think you have, but just in case, have you start htop in root? 😅

Try to show kernel threads if that’s not already the case.

Finally, you may just have a lot of small programs…

@Ernest1337 @unfa (I see a lot of answers about cache and swap, I don’t think it’s a cache problem nor a swap/swapiness problem, from the screen you shared, it’s perfectly fine on these things).

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!