Linux Doesn't free up cached RAM automatically!

Linux Doesn't free up cached RAM automatically!

Hello everyone,
I am Harsh and I have been using garuda for quite a while now. I have been facing an issue where the RAM gets almost full. I have 8GB RAM and still due the issue my applications lag even when I have only Discord, Firefox and VS Code open. I have read the "Linux ate my ram" article and am aware that Linux caches files takes up ram. And as per my understanding linux should free up cached ram if other applications need it. But in my case it doesn't and I can't tolerate the severe lagging of applications which doesn't happen in windows. What are the possible solutions to this.
Can I put a cap on the amount of ram linux can use for cache purpose lets say I allow only 3GB for cache.
Here is my system information.

System:    Kernel: 5.15.2-zen1-1-zen x86_64 bits: 64 compiler: gcc v: 11.1.0
parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen root=UUID=8333eb70-eab3-44cb-91de-fae6fa1e114e
rw [email protected] quiet splash rd.udev.log_priority=3 vt.global_cursor_default=0
systemd.unified_cgroup_hierarchy=1 loglevel=3
Desktop: KDE Plasma 5.23.3 tk: Qt 5.15.2 info: latte-dock wm: kwin_x11 vt: 1 dm: SDDM
Distro: Garuda Linux base: Arch Linux
Machine:   Type: Laptop System: ASUSTeK product: TUF Gaming FX505DT_FX505DT v: 1.0 serial: <filter>
Mobo: ASUSTeK model: FX505DT v: 1.0 serial: <filter> UEFI: American Megatrends v: FX505DT.316
date: 01/28/2021
Battery:   ID-1: BAT0 charge: 40.7 Wh (100.0%) condition: 40.7/48.1 Wh (84.6%) volts: 12.7 min: 11.7
model: FX50442 type: Li-ion serial: N/A status: Full
CPU:       Info: Quad Core model: AMD Ryzen 7 3750H with Radeon Vega Mobile Gfx bits: 64 type: MT MCP
arch: Zen family: 17 (23) model-id: 18 (24) stepping: 1 microcode: 8108102 cache: L2: 2 MiB
flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm bogomips: 36732
Speed: 2731 MHz min/max: 1400/2300 MHz boost: enabled Core speeds (MHz): 1: 2731 2: 2521
3: 2906 4: 2929 5: 2943 6: 1227 7: 2942 8: 2787
Vulnerabilities: Type: itlb_multihit status: Not affected
Type: l1tf status: Not affected
Type: mds status: Not affected
Type: meltdown status: Not affected
Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via prctl
Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer sanitization
Type: spectre_v2
mitigation: Full AMD retpoline, IBPB: conditional, STIBP: disabled, RSB filling
Type: srbds status: Not affected
Type: tsx_async_abort status: Not affected
Graphics:  Device-1: NVIDIA TU117M [GeForce GTX 1650 Mobile / Max-Q] vendor: ASUSTeK driver: nvidia
v: 495.44 alternate: nouveau,nvidia_drm bus-ID: 01:00.0 chip-ID: 10de:1f91 class-ID: 0300
Device-2: AMD Picasso vendor: ASUSTeK driver: amdgpu v: kernel bus-ID: 05:00.0
chip-ID: 1002:15d8 class-ID: 0300
Device-3: IMC Networks USB2.0 HD UVC WebCam type: USB driver: uvcvideo bus-ID: 3-1:2
chip-ID: 13d3:56a2 class-ID: 0e02 serial: <filter>
Display: x11 server: X.Org compositor: kwin_x11 driver: loaded: amdgpu
note: n/a (using device driver) display-ID: :0 screens: 1
Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.0x11.2") s-diag: 582mm (22.9")
Monitor-1: eDP-1 res: 1920x1080 hz: 144 dpi: 142 size: 344x193mm (13.5x7.6")
diag: 394mm (15.5")
OpenGL: renderer: AMD Radeon Vega 10 Graphics (RAVEN DRM 3.42.0 5.15.2-zen1-1-zen LLVM 13.0.0)
v: 4.6 Mesa 21.2.5 direct render: Yes
Audio:     Device-1: NVIDIA vendor: ASUSTeK driver: snd_hda_intel v: kernel bus-ID: 01:00.1
chip-ID: 10de:10fa class-ID: 0403
Device-2: AMD Family 17h HD Audio vendor: ASUSTeK driver: snd_hda_intel v: kernel
bus-ID: 05:00.6 chip-ID: 1022:15e3 class-ID: 0403
Sound Server-1: ALSA v: k5.15.2-zen1-1-zen running: yes
Sound Server-2: JACK v: 1.9.19 running: no
Sound Server-3: PulseAudio v: 15.0 running: no
Sound Server-4: PipeWire v: 0.3.40 running: yes
Network:   Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet vendor: ASUSTeK driver: r8169
v: kernel port: e000 bus-ID: 02:00.0 chip-ID: 10ec:8168 class-ID: 0200
IF: enp2s0 state: down mac: <filter>
Device-2: Realtek RTL8822CE 802.11ac PCIe Wireless Network Adapter vendor: AzureWave
driver: rtw_8822ce v: N/A modules: rtw88_8822ce port: d000 bus-ID: 04:00.0 chip-ID: 10ec:c822
class-ID: 0280
IF: wlp4s0 state: up mac: <filter>
Bluetooth: Device-1: IMC Networks Bluetooth Radio type: USB driver: btusb v: 0.8 bus-ID: 1-4:3
chip-ID: 13d3:3548 class-ID: e001 serial: <filter>
Report: bt-adapter ID: hci0 rfk-id: 5 state: down bt-service: enabled,running rfk-block:
hardware: no software: no address: <filter>
Drives:    Local Storage: total: 476.94 GiB used: 60.56 GiB (12.7%)
SMART Message: Unable to run smartctl. Root privileges required.
ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Micron model: 2200V MTFDHBA512TCK size: 476.94 GiB
block-size: physical: 512 B logical: 512 B speed: 31.6 Gb/s lanes: 4 type: SSD serial: <filter>
rev: P1MA0V4 temp: 45.9 C scheme: GPT
Partition: ID-1: / raw-size: 48.83 GiB size: 48.83 GiB (100.00%) used: 12.33 GiB (25.3%) fs: btrfs
dev: /dev/nvme0n1p6 maj-min: 259:6
ID-2: /boot/efi raw-size: 260 MiB size: 256 MiB (98.46%) used: 30.8 MiB (12.0%) fs: vfat
dev: /dev/nvme0n1p1 maj-min: 259:1
ID-3: /home raw-size: 48.83 GiB size: 48.83 GiB (100.00%) used: 12.33 GiB (25.3%) fs: btrfs
dev: /dev/nvme0n1p6 maj-min: 259:6
ID-4: /var/log raw-size: 48.83 GiB size: 48.83 GiB (100.00%) used: 12.33 GiB (25.3%) fs: btrfs
dev: /dev/nvme0n1p6 maj-min: 259:6
ID-5: /var/tmp raw-size: 48.83 GiB size: 48.83 GiB (100.00%) used: 12.33 GiB (25.3%) fs: btrfs
dev: /dev/nvme0n1p6 maj-min: 259:6
Swap:      Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default)
ID-1: swap-1 type: partition size: 6.01 GiB used: 51.9 MiB (0.8%) priority: -2
dev: /dev/nvme0n1p8 maj-min: 259:8
ID-2: swap-2 type: zram size: 7.27 GiB used: 6.5 GiB (89.4%) priority: 100 dev: /dev/zram0
Sensors:   System Temperatures: cpu: 67.0 C mobo: N/A gpu: amdgpu temp: 67.0 C
Fan Speeds (RPM): cpu: 2800
Info:      Processes: 324 Uptime: 9h 55m wakeups: 5 Memory: 7.27 GiB used: 6.85 GiB (94.3%) Init: systemd
v: 249 tool: systemctl Compilers: gcc: 11.1.0 clang: 13.0.0 Packages: pacman: 1437 lib: 365
Shell: fish v: 3.3.1 default: Bash v: 5.1.8 running-in: konsole inxi: 3.3.08

In the above system info you can notice that 6.85/7.27 GB is used when Firefox(with around 5 tabs), discord and VS Code were opem.

*le Ignore lol - totally WAS reading it wrong.
You're out of disk space which probably means your swap is useless and it's RAM or crash ;p (unless I'm reading that wrong you might want to deal with your disk first ;))

Basically all the firefox cache that is normally written to disk has no where to write so the websites just bloat it up while it's forced into RAM until you reach critical mass.

1 Like

What is your RAM usage and availability?


free -m

(You'll probably have to install ps_mem)


That is USED memory, it's not including cached memory in that calculation.

You say you "only" have ... & Firefox & ... but Firefox, like any browser can use 100s of GBs of memory depending on the number and complexity of the tabs you have open, let alone whatever you're running in VS code.

It's like me saying "I've read every book in the Library" without defining whether I'm talking about a library with one childs colouring book or the Library of Alexandria the day before it burned down.


This seems OK

1 Like

Indeed, I WAS reading it wrong. I just ran an inxi -Faz here and it's the way it dumps it at first glance looks like he's completely out of writable space.


There, there. Reading is hard. I even demonstrated it after you (though different difficulty).

1 Like

It's this whacky btrfs ;p -Not used to it yet :slight_smile:


Good luck, Chuck. I've been running it off-and-on for a bit more than a year and still can't quite wrap my head around it. It seems too fluid, as if it can be anything you want it to be but you'd better get it right if you want the filesystem to be performant (or even boot). Too many frickin' ampersands!

I'm not used to that. I like filesystems that stay in one, logical place. Maybe it's because I'm approaching 70 and have burnt out wasted too many braincells along the way, I dunno.

Correct me if I'm wrong, but I think the newest Arch ISO (or the next one's) "Archinstall* routine, sets up BTRFS subvolumes similar to Garuda's--snappable, etc. I know they've been working on it in the Arch .git repositories, anyway, and there was talk of releasing it in December. ("Archinstall" is Arch's guided installation routine similar to their old, discontinued official AIF.)


Yeah you'd have to really dig into the abstraction to see what's up. I mean the volumes/partitions are basically still just folders with a leading @ in the name so le wha? Yesterday when I was trying to fix my bootloader I found a few very odd things about btrfs as a side effect. However I don't see why info dump reports each one @ 100%. Hey 100% of your drive is used 100% x 7 so you now have a magical 700% drive?! Anyhow this is a tad off topic other than when I was looking his sys info over I had that WHA EVERY DRIVE IS 100%? I'd never noticed the sysdump shows like that...however a lot of times since I have to horizontally scroll to see that I'd probably missed it by never scrolling in that section but rather lower down for the GPU/Audio bits.

1 Like

LOL, my pc doesn't hang even with 11 tabs of firedragon, telegram, clion, terminal and document viewer running simultaneously on a weak 7 year old machine with just 4GB RAM, running Garuda Linux Cinnamon edition.

Back to topic. It is not possible that you have consumed all your RAM and SWAP, with just 3 programmes.

Kindly reboot your laptop more often.

That's still a lot of applications. Mine pc

Processes: 216 Uptime: 3h 25m wakeups: 0 Memory: 3.72 GiB used: 2.94 GiB (79.1%)

We just can't guess which process is eating your RAM. Kindly post

free -h

As already asked in above post by @ jonathon.


1 Like

PMSL, this is apparently the thread where no one can read (myself and nPhyn1T3 so far anyway) :upside_down_face:

1 Like

I wish I could get my systems to use more RAM...and the sinus crap is really gone from brain fog to brain dead this week.

Point up? What the hell man we're discussing memory usage not nose picking! ;p


Thank You Everyone for spending time in reading and replying to my query. Sorry for so late response from my side. Actually I got so upset that I didn't boot into garuda till today. So after reading all the answers I conclude that:

  1. I should reboot more frequently (I have a terrible habit of just leaving my pc on lock screen)
  2. I am running out of disk space (Maybe I need to create a swap partition, while installing I chose the option where garuda creates partition on its own). Please suggest me some link/tutorial for doing this.
    Here is the output of "df" command. I don't see any partition which is running short of memory.
Filesystem     1K-blocks     Used Available Use% Mounted on
dev              3753436        0   3753436   0% /dev
run              3810308    18056   3792252   1% /run
/dev/nvme0n1p6  51201024 13127532  37816452  26% /
tmpfs            3810308        0   3810308   0% /dev/shm
/dev/nvme0n1p6  51201024 13127532  37816452  26% /home
/dev/nvme0n1p6  51201024 13127532  37816452  26% /root
/dev/nvme0n1p6  51201024 13127532  37816452  26% /srv
/dev/nvme0n1p6  51201024 13127532  37816452  26% /var/cache
/dev/nvme0n1p6  51201024 13127532  37816452  26% /var/log
/dev/nvme0n1p6  51201024 13127532  37816452  26% /var/tmp
/dev/nvme0n1p1    262144    31564    230580  13% /boot/efi
tmpfs            3810308      552   3809756   1% /home/guest
tmpfs            3810312     9548   3800764   1% /tmp
tmpfs             762060   224072    537988  30% /run/user/1000
/dev/nvme0n1p7  23899984 13890720   8772172  62% /run/media/mucchu/075b6c5c-6b1a-46ea-8ae6-570f31c1d3d0

The next time I face the lag I will surely provide the output of free -m and ps_mem

Again thank you all.

Thank you for your reply. Can you share any article that can help me do a fix.

Outside some swapiness tutorials I've got nothing I can really share. I typically have the opposite issue where I have gobs of free RAM that's ignored while the swap file is like a prime time New York subway car (crammed full to the nuts).

Given my work laptop has half the RAM your machine does (it's OLD and lacks the problem I mentioned about Gobs-O-RAM heh) and I don't have those issues (but I don't run KDE for this reason) I'd play around with a few things.

  • Disable the ZRAM-generator in the Garuda-Assistant so things have to write to disk rather than RAM.

  • Open your browsers task manager and see if a specific webpage or extension is being a pig (or has a memory leak). Normally the browser task manager can be opened by right clicking in the tab bar where there are no tabs. This can be tricky if you have a small screen so you might need to open it with only one of your normal tabs open then open the rest after. Then go about your business and when things get bad you have it open to see if anything has gone nuts.

  • Try a different browser. Discord can be a pig and perhaps Firefox is just caching too much crap. (Just don't add Chome to the list of browsers to try and see next point)

  • Disable Firefox cache. Just don't let it save anything outside immediate working memory.

  • Disable all the fancy crap in KDE (you're on an IGP/APU so system memory is video memory i.e. all those fancy shadows/wobbles, transparency, fade in's and slide outs may be adding to the problem)

1 Like

No, you're not. He was being a derpy old Derphead.


Indeed I read the inxi wrong. Rather be a herpderp than a burpderp :wink:

1 Like

THat's how zram works. As unused ram is wasted ram