Have you ever looked at your system monitor and realized that nearly all your RAM is gone? Today, I hit 13 GiB of usage out of 15 GiB, despite not having any major applications visibly open.
In this post, I’ll walk through how I diagnosed the issue and recovered 9 GiB of RAM in just a few minutes.
Running a simple free -h revealed a concerning state:
total used free shared buff/cache available
Mem: 15Gi 13Gi 304Mi 397Mi 2.3Gi 1.8Gi
Only 300MB of free RAM! While Linux uses memory for caching, the “available” column showed only 1.8GB, meaning the rest was actively “held” by processes.
To find out what was eating the memory, I used ps to sort processes by memory consumption:
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head -n 10
The result was immediate:
qemu-system-x86_64 was using 52.2% of my RAM (~7.8 GiB).This process is a Virtual Machine (QEMU). On my system, it was associated with Docker Desktop. Even if no containers are doing heavy work, the VM itself reserves a massive chunk of RAM.
To fix this, I followed a two-step approach:
Since I wasn’t using Docker at the moment, I stopped the service:
sudo systemctl stop docker.socket docker
Linux keeps a “Page Cache” of files you’ve recently accessed. While this is normally good for performance, clearing it can reveal exactly how much “real” RAM you have left.
sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches
After these steps, another check with free -h showed:
total used free shared buff/cache available
Mem: 15Gi 4.1Gi 9.7Gi 361Mi 2.2Gi 11Gi
We went from 13 GiB used to 4.1 GiB used. Mission accomplished!
If you want to keep a closer eye on your memory without opening a heavy GUI, I highly recommend installing these CLI tools:
top.
htop in your terminal.F6: Sort by memory (%) or CPU (%).F3: Search for a specific process (e.g., “docker”).F9: Kill a process safely.q: Quit.smem -tw: Shows total memory usage across the system.smem -u: Shows memory usage per user.smem -rk: Sorts by memory and shows values in MB/GB (human-readable).Summary Tip: If your RAM is low, always check for hidden Virtual Machines or Docker instances first. They are often the stealthy consumers!
Happy debugging! 🛠️📉
Powered by Jekyll and Minimal Light theme.