DEV Community

Zaw Htut Win
Zaw Htut Win

Posted on

Slow Ubuntu ? Check the Swap

Ubuntu 20.0 OS that I was using had been stopped working several time lately. Today I checked the "htop" when the computer become so slow.
The culprit is the swap size, I'm using 2GB swap file and it was hitting to the maximum point, red colored. My laptop has 8GB of physical memory. According to the documentations, the optimal swap file size must equal to physical memory. So I execute the following commands.

swapon --show
sudo swapoff /swapfile
sudo rm  /swapfile
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Enter fullscreen mode Exit fullscreen mode

Then viola, I'm opening VSCode, running Mongodb, Node.js, ReactJs and 2 windows of Firefox. VSCode is still functioning. A good day for me yeah.

Top comments (0)