我已经编写了一个小的vbscript程序来查询WindowsXP(最终也是2003/2008服务器)下的页面文件使用情况,但我得到的数据似乎很奇怪。
这是程序:
Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
for i = 1 to 10
Set qry1 = wmi.ExecQuery ("Select * from Win32_PageFileSetting")
Set qry2 = wmi.ExecQuery ("Select * from Win32_PerfRawData_PerfOS_PagingFile")
initial = 0
maximum = 0
For Each obj in qry1
initial = initial + obj.InitialSize
maximum = maximum + obj.MaximumSize
Next
For Each obj in qry2
if obj.Name = "_Total" then
Wscript.Echo _
" Initial size: " & initial & _
" Maximum size: " & maximum & _
" Percent used: " & obj.PercentUsage & _
""
end if
Next
qry1 = none
qry2 = none
WScript.sleep (1000)
Next
输出:
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
Initial size: 1512 Maximum size: 3024 Percent used: 21354
关于msdn的doco声明:
PercentUsage
Data type: uint32
Access type: Read-only
Qualifiers:
DisplayName ("% Usage")
CounterType (537003008)
DefaultScale (0)
PerfDetail (200)
Percentage of the page file instance in use. For more information,
see the PageFileBytes property in Win32_PerfRawData_PerfProc_Process.
现在看来这是非常直接的。为什么我的3G页面文件使用21000%的分配空间?大约630克,但是
pagefile.sys
只有1.5克(我的整个硬盘只有186克)。
更新:
当我从同一个领域
Win32_PerfFormattedData_PerfOS_PagingFile
,我得到了一个更合理的值5,但这似乎仍然不符合任务管理器,它显示了1.06g的使用量超出了3g的最大值。