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.

  • 2
    If you can demonstrate that Firefox is not releasing memory from closed tabs, then please file a bug report with Mozilla, the developer of Firefox. – user535733 Jan 09 '24 at 02:20
  • Maybe see this answer https://askubuntu.com/a/1319818/231142 where I use the command of inxi to view the CPU usage and RAM usage of Firefox (I also do Chrome in there for comparisons). Maybe something in there might help you determine where your problem is actually happening. – Terrance Jan 09 '24 at 03:10
  • I've noted that extensions on firefox can cause ram leakage. The best way to fix that is to either restart firefox OR run firefox without the extensions being used; bugs may need to be filed against extensions instead (or be a combination of firefox when used with specific extensions). If you're using extensions, they maybe your problem (I've also found those same extensions in chromium or google-chrome have the same issue) – guiverc Jan 09 '24 at 03:27
  • This is most likely not a bug report, and it is most likely happening because of https://www.linuxatemyram.com/ and high swap usage. – Archisman Panigrahi Jan 09 '24 at 05:48

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.

Archisman Panigrahi
  • 28,338
  • 18
  • 105
  • 212