Solution: Firefox Hanging / Freezing on Linux

By Angsuman Chakraborty, Gaea News Network
Tuesday, March 31, 2015

I use CentOS 5.5 as my Desktop OS. Cent OS is a very stable Linux OS and is widely used in servers worldwide. And yet my Firefox used to regularly crash. By crash I mean the machine freezes up completely. Only recourse is to either reboot it or somehow execute the kill command and wait for a very long period for it to get accidentally recognized. After investigating on this I found the solution and realized this is not just a CentOS issue but can occur in any Linux system.

After analyzing with top when Firefox has slowed down and close to hanging, I realized that the machine is running out of swap space. This machine has 4GB of memory which should be enough in most cases but I am a power user.

The solution is simple as well as elegant. In Linux you can convert any file to swap file and add it to increase your swap space. here is what I did:

First create an empty file of say 1GB (1GB = 1024MB) and name myswapfile:

sudo dd if=/dev/zero of=/myswapfile bs=1M count=1024

Now restrict access to the swap file:

sudo chmod 600 /myswapfile

Now convert it to swap file:

sudo mkswap /myswapfile

Then add it to swap space:

sudo swapon /myswapfile

Finally check the current swap size with:

sudo swapon -s

That was easy, wasn’t it?

Note: If you are already logged in as root then you don’t have to prefix every line with sudo.

Filed under: Firefox, Linux
will not be displayed