My RAM is getting clogged with cache

After starting the system for 5 minutes, the cache reaches 1.5 GB. And after a while, the RAM is 100% full. I usually use chrome and sometimes phpstorm. I have 6gb ram and 2.3gb swap. I have already tried clearing the cache with echo 1, 2 and 3. This clears no more than 200MB of cache.

free -h (about 10 minuts from system start):

          total        used        free        shared     buff/cache   available
Mem:       5,7Gi       1,9Gi       1,5Gi      599Mi      1,3Gi              3,0Gi
Swap:      2,3Gi          0B         2,3Gi

df -h (i think problem here, but i don’t know how to fix it, programs that i use are only in the snap):

dev                  2,9G            0  2,9G            0% /dev
run                  2,9G         1,7M  2,9G            1% /run
/dev/sda5     223G         123G   90G           58% /
tmpfs             2,9G         236M  2,7G            9% /dev/shm
/dev/loop3          62M          62M     0          100% /var/lib/snapd/snap/core20/1328
/dev/loop0         128K         128K     0          100% /var/lib/snapd/snap/bare/5
/dev/loop1          56M          56M     0          100% /var/lib/snapd/snap/core18/2284
/dev/loop5          66M          66M     0          100% /var/lib/snapd/snap/gtk-common-themes/1519
/dev/loop4         165M         165M     0          100% /var/lib/snapd/snap/gnome-3-28-1804/161
/dev/loop6         587M         587M     0          100% /var/lib/snapd/snap/phpstorm/250
/dev/loop8          44M          44M     0          100% /var/lib/snapd/snap/snapd/14295
/dev/loop2          62M          62M     0          100% /var/lib/snapd/snap/core20/1270
/dev/loop7         259M         259M     0          100% /var/lib/snapd/snap/qt551/39
/dev/loop9          44M          44M     0          100% /var/lib/snapd/snap/snapd/14549
tmpfs              2,9G          58M  2,9G            2% /tmp
/dev/sda1           99M         274K   99M            1% /boot/efi
tmpfs              586M         116K  586M            1% /run/user/1000
/dev/loop10        587M         587M     0          100% /var/lib/snapd/snap/phpstorm/255

The cache is not “clogged”, it’s normal that it will fill up. Unused RAM is wasted RAM.

❯ free -h
               total        used        free      shared  buff/cache   available
Mem:            31Gi       5.6Gi       5.2Gi       455Mi        20Gi        24Gi
Swap:          4.0Gi          0B       4.0Gi

See https://www.linuxatemyram.com/

3 Likes

But my computer freezes and the cache only grows while the computer is running until the computer freezes completely.

Monitor activity with htop to see where the ram goes.

I can see you have multiple snaps. Avoid this and use repository apps whenever possible.

Thats an entirely different issue to linux optimizing RAM use by utilizing cache.

If your system freezes … then ask about that … and provide decent information … such as from any helpful guide like [HowTo] Provide System Information

1 Like