Swapping is necessary for two important reasons. First, when the
system requires more memory than is physically available, the kernel
swaps out less used pages and gives memory to the current application
(process) that needs the memory immediately. Second, a significant
number of the pages used by an application during its startup phase
may only be used for initialization and then never used again.
view how and when swap memory is used in linux ?