Q:

What is the meaning of running out of swap?

In linux machines for many scenarios we might get errors Running out of swap. what exactly it means. Is it similar to thrashing ? Are Running out of space and running out of swap are similar terms ? How can we find fix these kind of errors ?

A:

The swap is a secondary (disk-based) storage for your RAM: if your application consumes too much memory, some parts of the RAM are swapped out  (moved) onto the hard disk, to make room for new memory requests. (This is happening under the assumption, that the swapped out memory won't be needed in the near future; if an application needs to access it again, the memory will be swapped in again (moved back to the RAM), probably triggering a swap out of another memory area first).
Swapping is usually rather slow, as it involves moving larger data chunks between RAM and hard-disk, and all applications have to wait until it has finished before they can continue. As such, it is meant as a security measure to avoid out-of-memory crashes, but you should try to avoid triggering swapping if possible.
Now the swap-space itself can either be a file or an entire partition, but in any case they have a limited size as well (either defined by the partition size on which they reside, or limited by your OS).
So if you need to swap out a lot of memory (or have a small swap space), you will sooner or later run out of swap.
There are basically two ways to "fix" the problem:

make your swap-space bigger
make your application consume less memory

extending swap space

first, try to add more RAM to your system. The more RAM you have, the less likely it is that the system needs swap out memory.

If this doesn't help (or is not possible), you might need to extend the actual available swap space:

first create a new swap area (either a file or a disk partition) using mkswap.
then enable the swap space, using swapon.
you can also make the changes persistent by adding an entry to your fstab file.

But really this might just make your "running out of swap" problem appear a little later, so read on:
reduce memory consumption
Today's computers have plenty of RAM.
Unless you are dealing with very large datasets or are running very many memory hungry applications in parallel, it is highly unlikely that you ever run out of RAM and/or swap space.
Unless, that is, one of your application has a memory leak and consumes an unbound amount of memory.
Try to find out which applications use up all the memory, and check whether they are leaking resources.

