top指令輸出的VIRT, RES 和SHR有什麼區別app
VIRT 意味着進程虛擬空間的大小, 是真實使用的內存,加上映射進程本身使用的內存(如, X server使用顯卡內存), 加上映射磁盤文件使用的內存(主要是加載共享程序庫文件), 加上與其餘進程共享的內存. VIRT表明進程當前時刻有多少內存能夠訪問. less
RES 意味駐留內存大小, 是當前進程真正佔用物理內存的精確反映. (直接與%MEM列相對應.) RES始終要比VIRT小, 由於多數程序依賴C庫文件.ide
SHR 表示VIRT裏有多少實際上是共享部分(庫文件使用的內存). 關係到庫文件裏, 並非整個的庫文件會駐留. 如, 若是程序僅用到了庫文件裏的少數函數, 整個庫文件會映射並被計算到VIRT和SHR裏, 但只有庫文件包含用到的函數那部分真正加載到內存並被計算到RES裏.函數
The difference among VIRT, RES, and SHR in top outputserver
VIRT stands for the virtual size of a process, which is the sum of memory it is actually using, memory it has mapped into itself (for instance the video card’s RAM for the X server), files on disk that have been mapped into it (most notably shared libraries), and memory shared with other processes. VIRT represents how much memory the program is able to access at the present moment.進程
RES stands for the resident size, which is an accurate representation of how much actual physical memory a process is consuming. (This also corresponds directly to the %MEM column.) This will virtually always be less than the VIRT size, since most programs depend on the C library.內存
SHR indicates how much of the VIRT size is actually sharable (memory or libraries). In the case of libraries, it does not necessarily mean that the entire library is resident. For example, if a program only uses a few functions in a library, the whole library is mapped and will be counted in VIRT and SHR, but only the parts of the library file containing the functions being used will actually be loaded in and be counted under RES.it