1

My PC is having 11GB RAM, Ubuntu 20.04 and it run terribly slow and laggy for daily tasks of a programmer. Under 10 tabs of Firefox, 1 or 2 IDE windows, Telegram.
I have suspicion over for a long time that Ubuntu is not free up RAM after I have closed Firefox tabs or 1 of IDE windows (Pycharm). For example, I have 8 Firefox tabs and 1 Pycharm window opening (just opening not running any script), then I open the 9th tabs, voila, the PC get laggy, over 10GB of RAM are being used. I immediately try to close as many tabs as possible, let say I have 4 tabs left. Still, over 10GB of RAM used.
I think to myself, maybe wait a little, so I go grab my lunch, after I return, still the same. Then I closed Firefox, 5GB of RAM freed up immediately. And after I open Firefox again, 4 tabs and 1 Pycharm windows now only take 6GB RAM.
That mean all those closed tabs does nothing, right? It not free the amount of RAM that closed tabs have used.

1 Answers1

0

Firstly, Linux does not automatically free up memory (see https://www.linuxatemyram.com/). It caches opened programs into memory, which it frees up when a new program is opened. But, that does not smoothly happen when the system is swapping the memory into the hard drive, which is inherently slow. Use ZRAM instead of traditional swapping, and it should become fast again. ZRAM compresses and stores additional memory in the RAM itself, and does not store anything in the (significantly) slower hard drives.

git clone https://github.com/foundObjects/zram-swap.git
cd zram-swap && sudo ./install.sh

Afterwards, comment out the entry for swap partition/swapfile in /etc/fstab, and reboot.