What could be stealthily eating my RAM?

Hey!

I’m completely stumped. I though I had a decent understanding on how to track memory usage on Linux, but this is beyond me.

When I start me laptop (Ryzen 7 3750H + RX5500M), typical memory usage is about 1 GB. If I keep it on for couple of days, it’ll gradually increase until it takes up most of my memory and than start eating swap as well. Which would be fine, if I could actually see what it is.

I started with htop, couldn’t find anything using more that 500 MB and decided to just kill everything until it frees up. I’ve killed almost everything I could and according to smem, was barely using any memory:

  PID User     Command                         Swap      USS      PSS      RSS
 1171 user   (sd-pam)                        2.6M   100.0K   289.0K   900.0K
  418 systemd-timesync /usr/lib/systemd/systemd-ti   776.0K   208.0K   387.0K     1.6M
  300 root     /usr/lib/systemd/systemd-ud     2.7M   708.0K   961.0K     2.4M
  426 root     /usr/lib/systemd/systemd-lo   496.0K     1.3M     1.8M     4.2M
 1170 user   /usr/lib/systemd/systemd --   944.0K     1.5M     2.3M     4.5M
  757 root     /usr/lib/accounts-daemon      332.0K     2.7M     2.8M     3.7M
  781 root     /usr/bin/wpa_supplicant -u    572.0K     2.9M     3.0M     3.8M
178720 root     login -- user                    0     1.6M     3.0M     6.0M
  423 dbus     /usr/bin/dbus-daemon --syst   544.0K     2.9M     3.1M     4.0M
    1 root     /sbin/init                    688.0K     2.2M     3.3M     6.0M
217826 root     -zsh                               0     2.3M     3.5M     6.4M
217825 root     sudo -i                            0     2.7M     4.5M     8.1M
217401 user   -zsh                               0     3.2M     4.5M     7.5M
194443 user   /usr/bin/pulseaudio --daemo     2.2M     5.8M     6.5M     8.7M
217852 root     python /usr/bin/smem -k            0    12.8M    13.2M    15.2M
  277 root     /usr/lib/systemd/systemd-jo   836.0K    20.7M    28.0M    36.6M

Yet free is telling a different story:

               total        used        free      shared  buff/cache   available
Mem:            13Gi       7.0Gi       5.3Gi        97Mi       1.3Gi       6.2Gi
Swap:          8.0Gi       3.2Gi       4.8Gi

After a reboot it all goes away. After couple of incidents like this it occurred to me to check tmpfs as files in there could contribute to the consumption. I’ve checked all of the tmpfs mountpoints, but they total to about 500 MB.

There are no zombie or defunct processes in ps or anything that would indicate a memory leak.

I don’t have any docker containers or virtual machines.

The only vague link I have is that it might be somehow linked to my Steam Proton usage. I think when I’m using Proton heavily in the day, it snow-piles faster, but I couldn’t confirm that by starting and closing stuff with it.

Do you guys have any thoughts on what could it be? I’m not even worried about rebooting as much as I’m curious how is that even possible.

Thank you.

TL;DR: Something’s eating my RAM, doesn’t show up in htop or smem. Where could it be?

Hello @Kasami :wink:

By default /tmp is a tmpfs and pamac uses that. When you install some AUR packages it uses by default /tmp ( if you didn’t change that) and therefore eat for the time of compiling and packaging a lot of ram. Then it is swapping ram which is not in use at the moment to the swap disk/file.

I guess this is eating your ram.

1 Like

https://linuxatemyram.com

3 Likes

Thanks for responding!

Yes, I figured that could be it, but I’ve checked all of the tmpfs mount points and they only total to like 500MB. Where did the other ones go and what’s using swap is still a question.

Thanks for responding!

It’s a nice useful link! Unfortunately it doesn’t really help me in this case as it falls under unhealthy behavior. As you can see from free output, available is hogged by something, swap usage is constantly increasing and at some point some programs become unusable as they fully go to swap due to lack of RAM available. OOM killer is at work too. Mostly just killing top process, though.

When there is otherwise no indication of cause and AMD is involved everything is possible.

For me AMD has been notoriously problematic I avoid AMD like plague. I admit I only have had few encounters with AMD but those encounters has only served as reminders to avoid AMD.

Graphic problems on laptops with dual-graphics is probably the highest ranking cause of issues for members of this forum.

Just a wild guess - KDE user?

Other suggestions is guess work as you are the only one knowing what programs and services are installed and running on your system.

Another wild guess KODI? extension doing crypto mining - either malware or on purpose?

EDIT: NOTE

Thanks for replying!

Surprisingly, it has been easier to deal with AMD for me than Nvidia’s GPU. It pretty much just works, with the exception of downgrading linux-firmware, but yeah, Intel’s iGPU are even easier to deal with.

Not KDE, but I’m using GNOME3.

I’ve shut down all the programs and services, with the exception of what’s listed in smem above. In either case, I guess I’m not even asking for application specific advice, but general understanding of how it is possible to have 6GB of RAM used by something, not available for freeing up and not showing up in htop \ smem \ ps

Not using KODI. Not doing any crypto mining either. Also checked nethogs just in case to make sure nothing dodgy is connecting somewhere as crypto miner would require node connection. Nothing.

Does anyone else have any thoughts on what could it be?