Oninit Logo
The Down System Specialists
+1-913-674-0360
+44-2081-337529
Partnerships Contact

Memory and Swap

There is a common misconception that paging should be avoided at all costs on a the Unix system. This is not the case, Unix is the paging based system. The problem seems to be understanding the difference between swap and paging. Paging will occur on a perfectly healthy system, swap should never occurred on a healthy system.

To muddy the waters, most Linux admins use the term swap when referrig to paging.

vmstat 5 5

procs   memory               page       disk            faults        cpu
r b w   swap  free  re mf pi po fr de sr f0 s3 s6 --  in   sy  cs  us  sy  id
0 0 0   9472  9100   0  0  1  0  1  0  0  0  0  0  0  18  861  74   8  30  62
0 0 0 182952  1980   0  1  1  0  3  0  1  0  2  0  0  39  369  75  22  78   0
0 0 0 182952  1980   0  0  0  0  0  0  0  0  0  0  0  32  284  73  21  79   0
0 0 0 182952  1980   0  0  0  0  0  0  0  0  0  0  0  33  367  76  20  80   0
0 0 0 182952  1980   0  0  0  1  1  0  0  0  0  0  0  33  425  73  21  79   0

When the machine is restarted the amount of swap used will be minimal, as time progresses the amount of swap used has slowly increased. Even though the process has stopped and the memory requirement no longer remains there might not be corresponding decrease in the swap column vmstat. The analogy here is with Informix’s log files, the logs files are marked as unused but are not physically cleared. Although swap should never be used, swap must be available for the process to start successfully. As the process starts, the kernel will ensure that there is enough swap available for the swappable image to be swapped if required. The kernel merely checks that there is space available and reserves it, nothing is written to these pages.   However, if there is no swap available then the reservation will be made against physical memory, in this case the area is flagged as unpageable.  Remember the swappable image size is not the same as the process image the size. A process will only be swapped out in its entirety when there is a severe memory shortage, typically when there is only three per cent of total memory available.

The main columns of interest in the vmstat are the scan and the demand level rate. The scan rate should be typically below 200, anything significantly higher than this can indicate a shortfall of memory. the demand for level can be seen as the churn rate of memory, this is can peak too quite high numbers but should fall back relatively quickly to around the hundred.

Note: the above relates to SVR4 Unix, the paging within the other flavours of Unix does not necessarily apply the same rules.

Note: these numbers should be monitored over time, a sudden spike in any of the values should not necessarily be a cause for alarm.

To discuss how Oninit ® can assist please call on +1-913-674-0360 or alternatively just send an email specifying your requirements.