Uhm.p.H wrote:You cannot be more wrong.LE_746F6D617A7A69 wrote:You should avoid to use swap memory at all costs
Avoid to use != Don't create a swap.
Try to use any modern OS with a 1GB of RAM and 16GB of swap - probably even a web browser will start to choke because of swappiness.
But of course this is the *only* reason.p.H wrote:You cannot be more wrong again.LE_746F6D617A7A69 wrote:Swap memory has just one purpose: to protect the system from triggering the OOM Killer.
All the swap-related kernel activity, like swapping-out "unused" memory pages (containing code or data that was not referenced in some defined period of time) is serving exactly this single purpose: avoid OOM situations.
The costs are obvious: the higher swap usage, the higher probability of hitting swapped page, what means deadly slowdown in task switching/data access.
The problem is very serious, most of time-critical applications are usually entirely disabling swapping of their RAM areas, f.e. by calling mlockall(MCL_CURRENT|MCL_FUTURE).
Yes, I've made a mistake regarding the term "sparse" - it was late night, and my knowledge of english have failed me - againp.H wrote:Sparse files cannot be used as swap. The kernel needs to map all the swap space to the underlying block device. Of course this is not possible with a sparse file which does not have allocated blocks for all its space. Swap files are a dirty hack which does not work with all files and filesystems.LE_746F6D617A7A69 wrote:use sparse files as a swap