The vmstat utility is very useful for detecting memory problems. As the UNIX OS performs memory management, UNIX keeps internal
statistics about the rate of page-out and page-in operations from RAM memory.
The vmstat utility displays these memory structures and shows the internals of memory activity.
Memory usage: the r and pi columns
For memory usage, we are primarily interested in only two columns: the run queue r and the page-in column pi. Whenever we experience a non-zero value for pi, we know that our server is swapping memory. Memory paging slows down Oracle transactions, and this is often reflected in the run queue r column. If the value of the r column exceeds the number of CPUs on your server, and you do not have CPU bottlenecks (where us plus sy equals 100) then you may be waiting for memory.
The following diagram contains information with respect to the vmstat output.
Based on the image, the row headers are:
kthr memory page faults cpu
r b avm fre re pi po fr sr cy in sy cs us sy id wa
Here's the tabular structure based on the headers:
| kthr | memory | page | faults | cpu |
|------|----------------|-----------------------------|---------------|--------------|
| r | b | avm | fre | re | pi | po | fr | sr | cy | in | sy | cs | us | sy | id | wa |
This table structure reflects the columns as seen in the image. If there are actual data rows you'd like to add, please provide or describe them, and I can complete the table for you.
Kernel thread data including r run queue.
Includes average memory avm, free memory free
Includes retained memory re, page-in pi, and page-out po
Includes user CPU us, system CPU sy, idle CPU id, and wait CPU wa
To receive a vmstat listing for each second, use the command below. As illustrated, a new output line appears each second after the vmstat command.
vmstat
In the case above, we see that we are not experiencing memory swapping because the pi column is zero.
Values in the r column (OS run queue) indicate tasks waiting for service. This could be due to
memory bottlenecks, but could also be due to CPU or disk I/O waits. Whenever the r (run queue) column exceeds the number of CPUs on your server, you are experiencing a bottleneck because tasks are waiting for service. If high run queue values are seen in conjunction with high page-in operations, you may have a memory problem.
The next lesson shows how to track OS statistics.