Ubuntu 20.04 LTS freezing about every 10-15 seconds

Solution 1:

Yes, Ubuntu 20.04 hangs/freezes even though I have 8 GB of RAM and an i7.

I could temporary fix this issue in my side, by expanding the swap partition from 2 GB to 16 GB

I am not sure but I think there is problem in Ubuntu 20.04 memory management. Here on my side it keep consuming memory, then when both memory and swap are full, the computer starts to freeze and hang.

The solution's steps are:

  1. Check the amount of swap you have

    grep SwapTotal /proc/meminfo
    
  2. Turn off the swap process

    sudo swapoff -a
    
  3. Resize the swap (in my case I expanded it to 16 GB)

    sudo dd if=/dev/zero of=/swapfile bs=1G count=16
    
  4. Attach the swap to the partition

    sudo mkswap /swapfile
    
  5. Activate swap (enable it)

    sudo swapon /swapfile
    
  6. See the new swap size

    grep SwapTotal /proc/meminfo
    

Done.


References:

  • Bogdan Cornianu - Change swap size in Ubuntu 18.04 or newer (thanks man)

Solution 2:

Temporary solution of mine:

  • Disable all sleep/blank/switch off from power management settings (set to never).
  • Change lock from Keyboard > Application Shortcuts from xflock4 to i3lock. Need to install i3lock first (apt install i3lock).
  • Disable or remove this extension if you install it.
  • Try opening your chrome then block url, hover your pointer above it and leave it at that state if none of above worked.
  • Don't leave your notebook charged for too long (ex: overcharged or even fully charged) while locking (for notebook user)

Worked in my case except it will freeze after around 1 hour. I use Xubuntu with Ubuntu 20.04.