3

I'm running Arch Linux with GNOME 3.38 X11, and have an issue where I'm at idle (after using the computer for a while and closing everything) using around 8-9GB of RAM.

I know about linxatemyram, and I don't think this is the issue, since free -m prints the following:

               total        used        free      shared  buff/cache   available
Mem:           62282        9059       29502         162       23720       52368
Swap:           8191           0        8191

Indicating that indeed I am using a lot of ram when running nothing. When I used to have 16GB I would also run out of memory frequently due to this issue, so I don't think it's some form of caching, since that would back down when my memory usage goes up.

Curiously the top memory usages don't add up to the amount it claims to have reserved either. Here's a paste of the results I get. I've been thinking for a while that something must be leaking, but I can't seem to find out what.

EDIT: Extra outputs. These were measured soon after a restart, so aren't representative. I will rerun and post after the same situation arises.

$ mount | grep tmpfs
dev on /dev type devtmpfs (rw,nosuid,relatime,size=31848276k,nr_inodes=7962069,mode=755,inode64)
run on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755,inode64)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,inode64)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,size=4096k,nr_inodes=1024,mode=755,inode64)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,size=31888716k,nr_inodes=409600,inode64)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=6377740k,nr_inodes=1594435,mode=700,uid=1000,gid=985,inode64)
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
dev              31G     0   31G   0% /dev
run              31G  1.7M   31G   1% /run
/dev/nvme0n1p3  450G  208G  219G  49% /
tmpfs            31G  737M   30G   3% /dev/shm
tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
tmpfs            31G   19M   31G   1% /tmp
tmpfs           6.1G  136K  6.1G   1% /run/user/1000
5
  • 1
    mount | grep tmpfs ? df -h ? Mar 3, 2021 at 9:53
  • I just restarted in order to do work today. Should I do this while the system has high RAM usage or is anytime fine?
    – Marcel
    Mar 3, 2021 at 11:03
  • 2
    You might have tmpfs mounted to /tmp and programs writing tons of data to it, which will eat your RAM and will not be shown by top unforunately Mar 3, 2021 at 11:22
  • Good suggestion! I added the information you requested.
    – Marcel
    Mar 3, 2021 at 11:28
  • 1
    smem can show more accurate information than top. Some useful parameters are smem -wkt for the system-wide totals, smem -mkt for file / shared memory mappings, and smem -kt for per-process values.
    – jpa
    Mar 3, 2021 at 18:28

2 Answers 2

7

Based on the information you've provided you indeed have tmpfs filesystems mounted at /tmp and /dev/shm which are not shown by top or other similar utilities.

Please, monitor these mount points usage via df and clean up data or stop applications writing data to them. Some applications create files and delete them right away and such files still take space. They can't be seen directly via e.g. ls or df but you can discover them this way:

sudo lsof -n | egrep "/tmp|/dev/shm" | grep deleted

Since this is the 20th time I'm seeing this question I've gone ahead and filed bug reports against top, free and htop:

https://gitlab.com/procps-ng/procps/-/issues/196

https://github.com/htop-dev/htop/issues/556

1
  • 1
    I share your reasoning, but I can't reproduce the OP's issue on my Arch: the size of a file created in a tmpfs /tmp shows up in free's shared (and Shmem in /proc/meminfo). If the file is deleted while used by a process, its size is counted either in /proc/meminfo's Shmem (showing up in free's shared) or in /proc/meminfo's AnonPages (then showing up in top's RES for the process). It seems to never "disappear" - though of course there may be something I missed.
    – fra-san
    Mar 3, 2021 at 14:33
1

If the issue is the 9GB of used memory, then run top and list processes by %MEM.

Perfectly normal. Linux, Windows and most other OSes like to cache everything they can. Memory is being used, but its not locked to that content. It can be freed and replaced with something else as fast as the disk reads roll.
You should only see lots of free memory when a big process (or a set of collectively big processes) just ended.

1
  • 2
    He seems to be asking about the used column reading 9 GB. Your answer appears to apply to the buff/cache column reading of 23 GB.
    – jpa
    Mar 3, 2021 at 18:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .