Linux

如何閱讀“頂部”。程序列表說程序有交換,但概述說沒有使用交換

  • January 14, 2014

top用來監控我的伺服器。交換行讀取

Swap: 1044220k total, 0k used, 1044220k free, 148544k cached

我已經O p按交換排序。

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP COMMAND 
 703 mysql     20   0  930m  43m 7092 S    0  8.9   0:00.66 886m mysqld                                                         
1555 www-data  20   0  346m 9792 3208 S    0  2.0   0:00.00 337m apache2                                                        
1559 www-data  20   0  347m  10m 3712 S    0  2.2   0:00.01 336m apache2                                                        
1567 www-data  20   0  345m 9448 2552 S    0  1.9   0:00.01 336m apache2                                                        
1557 www-data  20   0  345m 9452 2556 S    0  1.9   0:00.01 336m apache2                                                        
1562 www-data  20   0  345m 9508 2344 S    0  1.9   0:00.01 336m apache2                                                        
1566 www-data  20   0  345m 9684 2684 S    0  1.9   0:00.02 335m apache2     

我想知道我應該怎麼讀這個。這是這些程序可用的交換嗎?

今天早上頂部顯示 mysqld 正在使用 1.1 GB 的交換空間,而我的交換空間的 30% 已用完。在向機器投擲更多 ram 之後mysqld886mtop 表示交換使用量為 0(這個數學似乎是有道理的)。所以我只是想知道交換列顯示的是什麼?為什麼交換概覽不反映交換列的總和?謝謝你。

它是通過從虛擬記憶體中減去物理記憶體來計算的:

SWAP = VIRT - RES

man top更多細節:

  o: VIRT  --  Virtual Image (kb)
     The  total amount of virtual memory used by the task.  It includes all code, data and shared libraries
     plus pages that have been swapped out and pages that have been mapped but not used.

  p: SWAP  --  Swapped size (kb)
     Memory that is not resident but is present in a task.  This is memory that has been  swapped  out  but
     could  include additional non-resident memory.  This column is calculated by subtracting physical mem‐
     ory from virtual memory.

  q: RES  --  Resident size (kb)
     The non-swapped physical memory a task has used.

引用自:https://serverfault.com/questions/424213