Swap memory

swap

I am using RAM for storing some of my database tables and the others are stored in hard disk.

Today I came to know that my processes are using swap memory.
Now what is swap memory and how can I detect that which process is using swap memory and how can i stop them from using it?

Best Answer

If you run out of physical memory, you use virtual memory, which stores the data in memory on disk. Reading from disk is several orders of magnitude slower than reading from memory, so this slows everything way down. (Exchanging data between real memory and virtual memory is "swapping". The space on disk is "swap space".)

If your app is "using swap", then you either need to use less memory or buy more RAM.

(Swap is useful because applications that aren't being used can be stored on disk until they are used. Then they can be "paged in" and run normally again. While it is not in memory, though, the OS can use that memory for something else, like disk cache. So it's a very useful feature, but if you don't have enough physical memory to run your program, you definitely need more memory. Fortunately, memory is really really cheap these days.)