各計數器理解及描述
1、Process\\Working Set
含義:
進(jìn)程工作集,是虛擬地址空間在物理內存中的那部分。包含了一個(gè)進(jìn)程內的各個(gè)線(xiàn)程引用過(guò)的頁(yè)面,即:Task Manager中的Mem Usage。
分析:
由于每個(gè)進(jìn)程工作集中包含了共享頁(yè)面,所以Process\\Working Set(_Total)值會(huì )大于實(shí)際的總進(jìn)程內存使用量。
2、Process\\Private Bytes
含義:
分配的私有虛擬內存總數,即私有的、已提交的虛擬內存使用量。即:Task Manager中的VM Size。
分析:
內存泄露時(shí)表現的現象是私有虛擬內存的遞增,而不是工作集大小的遞增。在某個(gè)點(diǎn)上,內存管理器會(huì )阻止一個(gè)進(jìn)程繼續增加物理內存大小,但它可以繼續增大它的虛擬內存大小。
3、Memory\\Available MBytes (Available Bytes、Available KBytes)
含義:
Available MBytes 是指以 MB 表示的可用物理內存量,此內存能立刻分配給一個(gè)進(jìn)程或系統使用。它是空閑列表、零列表和備用列表的大小總和。
分析:
至少要有10% 的物理內存值,最低限度是4 MB。
頁(yè)面狀態(tài):
備用:頁(yè)面原先屬于某個(gè)工作集,但現在被去除了。該頁(yè)面自從最后一次被寫(xiě)到磁盤(pán)后一直未被修改過(guò),PTE(Page Table Entry)仍然指向該物理頁(yè)面,不過(guò)已標記為無(wú)效的和正在轉移中。
空閑:頁(yè)面是空閑的,但它包含了未特別指明的臟數據。(需要用零初始化,否則不能交給用戶(hù)進(jìn)程)
零化:頁(yè)面是空閑的,并且已經(jīng)被零頁(yè)面線(xiàn)程初始化為零了。
4、Memory\\Page Faults/sec
含義:
Page Faults/sec 是每秒鐘出錯頁(yè)面的平均數量。由于每個(gè)錯誤操作中只有一個(gè)頁(yè)面出錯,計算單位為每秒出錯頁(yè)面數量,因此這也等于頁(yè)面錯誤操作的數量。這個(gè)計數器包括硬錯誤(那些需要磁盤(pán)訪(fǎng)問(wèn)的)和軟錯誤(在物理內存的其他地方找到的錯誤頁(yè))。許多處理器可以在有大量軟錯誤的情況下繼續操作。但是,硬錯誤可以導致明顯的拖延,因為需要訪(fǎng)問(wèn)磁盤(pán)。
5、Memory\\Page Reads/sec
含義:
PageReads/sec是讀取磁盤(pán)以解析硬頁(yè)面錯誤的次數。它顯示讀取操作的數量,它并不考慮每個(gè)操作的頁(yè)面數量。當一個(gè)進(jìn)程引用一個(gè)虛擬內存的頁(yè)面,而此虛擬內存位于工作集以外或物理內存的其他位置,并且此頁(yè)面必須從磁盤(pán)檢索時(shí),就會(huì )發(fā)生硬頁(yè)面錯誤。此計數器是引起系統范圍內延遲的主要指示器。它包含讀取操作以滿(mǎn)足文件系統緩存(通常由應用程序請求)和非緩存映射內存文件的錯誤。比較內存的值\\Pages Reads/sec 與內存的值\\Pages Input/sec 來(lái)決定每個(gè)操作取讀的平均頁(yè)面數量。
通俗含義:
頁(yè)的硬故障,Page/sec的子集,是為了解決硬錯誤,從硬盤(pán)讀取的次數。
分析:
閾值為>5,越低越好。大數值表示磁盤(pán)讀而不是緩存讀。持續大于5的值,表明內存的讀請求發(fā)生了較多的缺頁(yè)中斷(page fault)。
說(shuō)明進(jìn)程的Working Set已經(jīng)不夠,使用硬盤(pán)來(lái)虛擬內存。此處為讀得次數,不關(guān)心讀取得頁(yè)數,比較大的值表明內存出現了瓶頸。
6、Memory\\Page Writes/sec
含義:
Page Writes/sec 是指為了釋放物理內存空間而將頁(yè)面寫(xiě)入磁盤(pán)的速度。只有頁(yè)面還在物理內存中時(shí)所做的更改才會(huì )寫(xiě)入磁盤(pán),因此這些頁(yè)面可能只保留數據而不保留代碼。這個(gè)計數器顯示寫(xiě)入操作,不計數每個(gè)操作中寫(xiě)入的頁(yè)數。
7、Memory\\Pages Input/sec
含義:
PagesInput/sec是以解析硬頁(yè)面錯誤從磁盤(pán)讀取的頁(yè)數。當一個(gè)進(jìn)程引用一個(gè)虛擬內存的頁(yè)面,而此虛擬內存位于工作集以外或物理內存的其他位置,并且此頁(yè)面必須從磁盤(pán)檢索時(shí),就會(huì )發(fā)生硬頁(yè)面錯誤。當夜面發(fā)生錯誤時(shí),系統嘗試將多個(gè)連續頁(yè)面讀入內存以充分利用取讀操作的優(yōu)點(diǎn)。請比較 Memory\\PagesInput/sec 的值和 Memory\\Page Reads/sec 的值以便決定每個(gè)取讀操作讀入內存的平均頁(yè)面數量。
8、Memory\\Pages Output/sec
含義:
PagesOutput/sec是指為了釋放物理內存空間而將頁(yè)面寫(xiě)入磁盤(pán)的頁(yè)數。只有在物理內存中更改時(shí)頁(yè)面才會(huì )寫(xiě)回到磁盤(pán)上,因此頁(yè)面可能只保留數據而不是代碼。高速的頁(yè)面輸出可能表示內存不足。當物理內存不足時(shí),Windows 會(huì )將頁(yè)面寫(xiě)回到磁盤(pán)以便釋放空間。
9、Memory\\Page/sec
含義:
Pages/sec是指為解決硬頁(yè)錯誤從磁盤(pán)讀取或寫(xiě)入磁盤(pán)的頁(yè)數。這個(gè)計數器是可以顯示導致系統范圍延緩類(lèi)型錯誤的主要指示器。它是 Memory\\PagesInput/sec 和 Memory\\Pages Output/sec的總和。是用頁(yè)數計算的,以便在不用做轉換的情況下就可以同其他頁(yè)計數如: Memory\\Page Faults/sec做比較,這個(gè)值包括為滿(mǎn)足錯誤而在文件系統緩存(通常由應用程序請求)的非緩存映射內存文件中檢索的頁(yè)。
分析:
一般如果pages/sec持續高于幾百,那么您應該進(jìn)一步研究頁(yè)交換活動(dòng)。有可能需要增加內存,以減少換頁(yè)的需求(你可以把這個(gè)數字乘以4k就得到由此引起的硬盤(pán)數據流量) 。Pages/sec 的值很大不一定表明內存有問(wèn)題,而可能是運行使用內存映射文件的程序所致。
10、Memory\\ % Committed Bytes In Use
含義:
%CommittedBytes In Use 是 Memory\\Committed Bytes 與 Memory\\Commit Limit之間的比值。Committed memory是已在頁(yè)面文件中保留空間的在用物理內存。Commit Limit是由頁(yè)面文件的大小而決定的。如果擴大了頁(yè)面文件,該比例就會(huì )減小。
※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
11、Memory\\ Committed Bytes
含義:
Committed Bytes 是指已被提交的(不是保留的)虛擬內存字節數。此數并不一定代表頁(yè)面文件的使用量,因為它包含了物理內存中從未被換出過(guò)的私有提交頁(yè)面。當然,如果一個(gè)進(jìn)程完全是非駐留的,則它代表所使用的頁(yè)面文件數量。
對應Task Manager的PF使用 (Current Commit Charge) 。頁(yè)面文件的使用量參見(jiàn)計數器:Paging File\\%Usage。
原文:
Numberof bytes of virtual (not reserved) memory that has been committed. Thisnumber doesn’t necessarily represent page file usage because itincludes private committed pages in physical memory that have neverbeen paged out. Rather, it represents the amount of page file spacethat would be used if the process was completely made nonresident.
分析:
NT的內存分配采用了兩步走的方法,首先,在虛地址空間上保留一段空間,這時(shí)操作系統并沒(méi)有分配物理內存,只是保留了一段地址。然后,再提交這段空間,這時(shí)操作系統才會(huì )分配物理內存。
Windows的地址空間有三種狀態(tài)。一種是COMMITED,表明該地址空間已和一塊內存相聯(lián)系;一種是RESERVED,表明該地址空間雖未與一塊內存相聯(lián)系但今后可能會(huì )用到,需要保留;一種是FREE,表明該地址空間與內存沒(méi)有聯(lián)系。
12、Memory\\ Commit Limit
含義:
Commit Limit 是指無(wú)需擴展頁(yè)面文件就可以提交的虛擬內存字節數。
原文:
Numberof bytes of virtual memory that can be committed without having toextend the paging files; if the paging files can be extended, thislimit is not hard.
Touse a reserved region of address space, you must allocate physicalstorage and then map this storage to the reserved region. This processis called committing physical storage. Physical storage is alwayscommitted in pages.
※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
13、Memory\\Pool Nonpaged Allocs
含義:
Pool Nonpaged Allocs 指在換換頁(yè)池中分派空間的調用數。它是用衡量分配空間的調用數來(lái)計數的,而不管在每個(gè)調用中分派的空間數是多少。
原文:
Showsthe number of calls to allocate space in the nonpaged pool. Thiscounter is measured in numbers of calls to allocate space, regardlessof the amount of space allocated in each call.
分析:
考察其自系統啟動(dòng)以來(lái)的增長(cháng)了10%以上,如果是,表明有潛在的嚴重瓶頸。
需要觀(guān)察Server\\Pool Nonpaged Failures,非頁(yè)面池分配失敗的次數。非零表示計算機的物理內存太小。
14、Memory\\Pool Nonpaged Bytes
含義:
Pool Nonpaged Bytes 指在非換頁(yè)池中的字節數,非換頁(yè)池是指系統內存(操作系統使用的物理內存)中可供對象(指那些在不處于使用時(shí)不可以寫(xiě)入磁盤(pán)上而且只要分派過(guò)就必須保留在物理內存中的對象)使用的一個(gè)區域。
疑問(wèn):Memory\\Pool Nonpaged Bytes 的計數方式與 Process\\Pool Nonpaged Bytes 的計數方式有什么不同。
通俗含義:
非換頁(yè)池中的當前大小,即Task Manager中的Kernel Memory→NonPaged。
15、Memory\\Pool Paged Allocs
含義:
Pool Paged Allocs 指在換頁(yè)池中分派空間的調用次數。它是用計算分配空間的調用次數來(lái)計算的,而不管在每個(gè)調用中分派的空間數是什么。
原文:
Showsthe number of calls to allocate space in the paged pool. This counteris measured in numbers of calls to allocate space, regardless of theamount of space allocated in each call.
16、Memory\\Pool Paged Bytes
含義:
Pool Paged Bytes 指在換頁(yè)池中的字節數,換頁(yè)池是系統內存(操作系統使用的物理內存)中可供對象(在不處于使用時(shí)可以寫(xiě)入磁盤(pán)的)使用的一個(gè)區域。
疑問(wèn):Memory\\Pool Paged Bytes 的計數方式與 Process\\Pool Paged Bytes 的方式有什么不同。
通俗含義:
換頁(yè)池的當前虛擬大小,即Task Manager中的Kernel Memory→Paged Virtual。
換頁(yè)池的當前物理(駐留)大小參見(jiàn)計數器Memory\\Poll Paged Resident Bytes。
分析:
也需要觀(guān)察Server\\Pool Paged Failures,頁(yè)面池分配失敗的次數。非零表示計算機的物理內存或頁(yè)面文件太小。
※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
17、Memory\\ Cache Bytes
含義:
系統工作集的總大小,其包括以下代碼或數據駐留在內存中的那一部分:系統緩存、換頁(yè)內存池、可換頁(yè)的系統代碼(Ntoskrnl.exe和驅動(dòng)程序),以及系統映射的視圖。
分析:
從字面意思上看,僅僅是指系統緩存,其實(shí)不然。
CacheBytes Memory\\System Cache Resident Bytes、Memory\\System DriverResident Bytes、Memory\\System Code Resident Bytes 和 Memory\\Pool PagedResident Bytes的總和。
18、Memory\\Cache Bytes Peak
含義:
Cache Bytes Peak 是系統啟動(dòng)后文件系統緩存使用的最大字節數量。這可能比當前的緩存量要大。這個(gè)計數器只顯示上一次觀(guān)察到的值;它不是一個(gè)平均值。
原文:
Showsthe maximum number of bytes used by the file system cache since thesystem was last started. This might be larger than the current size ofthe cache.
19、Memory\\Cache Faults/sec
含義:
Cache Faults/sec 指在文件系統緩存中找不到要尋找的頁(yè)而需要從內存(軟錯誤)的其他地方或從磁盤(pán)(硬錯誤)的其他上檢索時(shí)出現的錯誤的速度。文件系統緩存活動(dòng)是大部分應用程序 IP 操作的可靠指示
器。這個(gè)計數器顯示錯誤的次數而不管每次操作中的出錯的頁(yè)數。
原文:
Showsthe rate, in incidents per second, at which faults occured when a pagethat was sought in the file system cache was not found and was beretrieved either from elsewhere in memory (a soft fault) or from disk(a hard fault). This counter shows the total number of faults, withoutregard for the number of pages faulted in each operation.
分析:
從文件系統緩存中查找數據,未命中的次數。這個(gè)值應該盡可能的低,較大的值表明內存出現短缺,緩存命中很低。
同時(shí)需要觀(guān)察Cache\MDL Read Hits%,MDL Read Hits 是指 Memory Descrīptor List 向文件系統緩存發(fā)出的請求命中緩存的百分比,例如:不需要磁盤(pán)訪(fǎng)問(wèn)即可為在緩存中的頁(yè)面提供內存訪(fǎng)問(wèn)。
值越大(接近100%),表明文件系統緩存效果越好。
20、Memory\\Demand Zero Faults/sec
含義:
DemandZero Faults/sec通過(guò)零化頁(yè)面來(lái)彌補分頁(yè)錯誤的平均速度。這個(gè)計數器顯示最近兩個(gè)保留取樣值的差,再除以取樣間隔。零化頁(yè)面是指先清空以前的資料,再將頁(yè)面用0來(lái)填滿(mǎn),這是Windows NT的安全性功能,這樣可以防止以前的資料外泄。這個(gè)計數器顯示的是錯誤數量,而不是重新獲取的頁(yè)面數量。
原文:
Showsthe average rate, in incidents per second, at which page faultsrequired a zeroed page to satisfy the fault. This counter displays thedifference between the values observed in the last two samples, dividedby the duration of the sample interval. Zeroed pages (pages emptied ofpreviously stored data and filled with zeroes) prevent processes fromseeing data stored by earlier processes that used the same memoryspace. This counter displays the number of faults, without regard tothe number of pages retrieved to satisfy the fault.
21、Memory\\Free System Page Table Entries
含義:
Free System Page Table Entries 指系統沒(méi)有使用的頁(yè)表項目。這個(gè)計數值僅顯示上一次的值,而不是一個(gè)平均值。
原文:
Shows the number of page table entries not in use by the system.
22、Memory\\Pool Paged Resident Bytes
含義:
換頁(yè)池所使用的物理內存,即Task Manager中的Kernel Memory→Paged Physical。
23、Memory\\System Cache Resident Bytes
含義:
System Cache Resident Bytes 是文件系統緩存可換頁(yè)的操作系統代碼的字節大小。此值只包括當前的物理頁(yè)面,而不包括當前未使用的虛擬內存頁(yè)面。它不等于“任務(wù)管理器”上顯示的系統緩存值。因此,此值會(huì )比文件系統緩存使用的實(shí)際虛擬內存要小。此值是 Memory\\System Code Resident Bytes 的組件,它代表當前在物理內存里的所有可換頁(yè)的操作系統代碼。
原文:
Showsthe size, in bytes, of pageable operating system code in the filesystem cache. This value includes only current physical pages and doesnot include any virtual memory pages that are not currently resident.It does not equal the System Cache value shown in Task Manager. As aresult, this value may be smaller than the actual amount of virtualmemory in use by the file system cache. This value is a component ofSystem Code Resident Bytes that represents all pageable operatingsystem code that is currently in physical memory.
通俗含義:
系統緩存所使用的物理內存。
24、Memory\\System Code Resident Bytes
含義:
SystemCode Resident Bytes 是操作系統代碼當前在物理內存的字節大小,此物理內存在未使用時(shí)可寫(xiě)入磁盤(pán)。此值是Memory\\System Code Total Bytes 的組件,它還包括磁盤(pán)上的操作系統代碼。Memory\\System CodeResident Bytes (和 Memory\\System Code Total Bytes)不包括必須留在物理內存的代碼,并且不能寫(xiě)入磁盤(pán)。
原文:
Showsthe size, in bytes, of operating system code currently in physicalmemory that can be written to disk when not in use. This value is acomponent of System Code Total Bytes, which also includes operatingsystem code on disk. System Code Resident Bytes (and System Code TotalBytes) does not include code that must remain in physical memory.
通俗含義:
Ntoskrnl.exe中可換頁(yè)代碼所使用的物理內存。
25、Memory\\System Code Total Bytes
含義:
SystemCode Total Bytes指當前在虛擬內存中的可換頁(yè)的操作系統代碼的字節數。這是用來(lái)衡量在不使用時(shí)可以寫(xiě)入到磁盤(pán)上的操作系統使用的物理內存的數量。這個(gè)值是通過(guò)將在Ntoskrnl.exe, Hal.dll 、啟動(dòng)驅動(dòng)器和用 Ntldr/osloader加載的文件系統中的字節的數相加得出的。這個(gè)計數器不包括必須保留在物理內存中并不能寫(xiě)入到磁盤(pán)上的代碼。
原文:
Showsthe size, in bytes, of pageable operating system code currently invirtual memory. It is a measure of the amount of physical memory beingused by the operating system that can be written to disk when not inuse. This value is calculated by adding the bytes in Ntoskrnl.exe,Hal.dll, the boot drivers, and file systems loaded by Ntldr/osloader.This counter does not include code that must remain in physical memory.
26、Memory\\System Driver Resident Bytes
含義:
System Driver Resident Bytes 指設備驅動(dòng)程序當前使用的可換頁(yè)的物理內存的字節數。它是驅動(dòng)程序的工作集(物理內存區域)。這個(gè)值為 Memory\\System Driver Total Bytes (也包括可以寫(xiě)入磁盤(pán)的驅動(dòng)程序
內存)的組件。無(wú)論 System Driver Resident Bytes 還是 System Driver Total Bytes都包括不能寫(xiě)入磁盤(pán)的物理內存。
原文:
Showsthe size, in bytes, of pageable physical memory being used by devicedrivers. The counter is the working set (physical memory area) of thedrivers. This value is a component of System Driver Total Bytes, whichalso includes driver memory that has been written to disk. NeitherSystem Driver Resident Bytes nor System Driver Total Bytes includesmemory that cannot be written to disk.
通俗含義:
可換頁(yè)的設備驅動(dòng)程序代碼所使用的物理內存。
27、Memory\\System Driver Total Bytes
含義:
SystemDriver Total Bytes指設備驅動(dòng)程序當前使用的可換頁(yè)的虛擬內存的字節數。當不使用時(shí)可換頁(yè)內存可以寫(xiě)入磁盤(pán)。它包括物理內存(Memory\\System DriverResident Bytes)和代碼以及寫(xiě)到磁盤(pán)中的數據。它是Memory\\System Code Total Bytes 的一個(gè)組件。
原文:
Showsthe size, in bytes, of pageable virtual memory currently being used bydevice drivers. Pageable memory can be written to disk when it is notbeing used. It includes physical memory (System Driver Resident Bytes)and code and data written to disk. This counter is a component ofSystem Code Total Bytes.
28、Memory\\Transition Faults/sec
含義:
Transition Faults/sec是在沒(méi)有額外磁盤(pán)運行的情況下,通過(guò)恢復頁(yè)面來(lái)解決頁(yè)面錯誤的速度。頁(yè)面錯誤包括頁(yè)面正被另一個(gè)共享此頁(yè)面的進(jìn)程使用,或在被修改的頁(yè)面列表上或待機列表上,或在發(fā)生頁(yè)面錯誤時(shí)正被寫(xiě)入磁盤(pán)。該技術(shù)器也等于錯誤的頁(yè)面數量,因為每一操作只有一個(gè)頁(yè)面錯誤。
原文:
Showsthe rate, in incidents per second, at which page faults were resolvedby recovering pages without additional disk activity, including pagesthat were being used by another process sharing the page, or that wereon the modified page list or the standby list, or that were beingwritten to disk at the time of the page fault. This counter is alsoequal to the number of pages faulted because only one page is faultedin each operation.
分析:
如果這個(gè)指標持續的居高不下說(shuō)明內存存在瓶頸,應該考慮增加內存。
29、Memory\\Write Copies/sec
含義:
Write Copies/sec 是指通過(guò)從物理內存中的其他地方復制頁(yè)面來(lái)滿(mǎn)足寫(xiě)入嘗試而引起的頁(yè)面錯誤速度。由于頁(yè)面只在被寫(xiě)入時(shí)才被復制,這是一個(gè)實(shí)用的共享數據方式;另外該頁(yè)面是共享的。這個(gè)計數器顯示的是復制次數,不考慮每次操作時(shí)中被復制的頁(yè)面數。
原文:
Showsthe rate, in incidents per second, at which page faults were caused byattempts to write that were satisfied by copying the page fromelsewhere in physical memory. This is an economical way of sharing datasince pages are only copied when they are written to; otherwise, thepage is shared. This counter shows the number of copies, without regardto the number of pages copied in each operation.
分析:
就是寫(xiě)時(shí)復制錯誤的比率。寫(xiě)時(shí)復制頁(yè)面保護機制是一種優(yōu)化,內存管理器利用它可以節約內存。
例如:兩個(gè)進(jìn)程正在共享三個(gè)頁(yè)面,每個(gè)頁(yè)面都被標記為寫(xiě)時(shí)復制,當其中一個(gè)進(jìn)程的任一線(xiàn)程對一個(gè)頁(yè)面執行寫(xiě)操作,則會(huì )產(chǎn)生一個(gè)內存管理錯誤。內存管理器不會(huì )將該錯誤報告為訪(fǎng)問(wèn)違例,而是在物理內存中分配一個(gè)新的讀/寫(xiě)頁(yè)面,并將原始頁(yè)面中的內容拷貝到新的頁(yè)面中,同時(shí)更新該進(jìn)程對應的頁(yè)面映射信息,使之指向新的頁(yè)面位置,然后解除異常,從而繼續進(jìn)行剛才的寫(xiě)指令。寫(xiě)操作成功,新拷貝的頁(yè)面現在對于執行寫(xiě)操作的進(jìn)程來(lái)說(shuō)是私有的,對于其他進(jìn)程是不可見(jiàn)的。
后序
本人參考《深入解析Windows操作系統》和網(wǎng)上的一些資料,通過(guò)自己的理解,形成了上文,有什么不足之處,敬請提出。
附:Task Manager說(shuō)明
物理內存:
總數(2088268):實(shí)際可用的物理內存;
可用數(1176636):備用列表、空閑列表、零列表的總值大??;
系統緩存(1230280):備用列表+系統工作集;
內存使用:
總數(926572):提交的總虛擬內存;
限制(5068816):在不擴展頁(yè)面文件的情況下最大的虛擬內存;
核心內存:
分頁(yè)數(95784):換頁(yè)池的虛擬大??;
未分頁(yè)(30552):非換頁(yè)池的物理大小。