| Index: base/process/process_metrics_win.cc
|
| diff --git a/base/process/process_metrics_win.cc b/base/process/process_metrics_win.cc
|
| index d2f0c935531071a092289637b9696a744c22ea9a..a9f7762dad637355694adfc32b7291dc47892942 100644
|
| --- a/base/process/process_metrics_win.cc
|
| +++ b/base/process/process_metrics_win.cc
|
| @@ -23,6 +23,21 @@ namespace {
|
| // System pagesize. This value remains constant on x86/64 architectures.
|
| const int PAGESIZE_KB = 4;
|
|
|
| +typedef enum _SYSTEM_INFORMATION_CLASS {
|
| + SystemMemoryListInformation = 80
|
| +} SYSTEM_INFORMATION_CLASS;
|
| +
|
| +struct SYSTEM_MEMORY_LIST_INFORMATION {
|
| + SIZE_T ZeroPageCount;
|
| + SIZE_T FreePageCount;
|
| + SIZE_T ModifiedPageCount;
|
| + SIZE_T ModifiedNoWritePageCount;
|
| + SIZE_T BadPageCount;
|
| + SIZE_T PageCountByPriority[8];
|
| + SIZE_T RepurposedPagesByPriority[8];
|
| + SIZE_T ModifiedPageCountPageFile;
|
| +};
|
| +
|
| typedef NTSTATUS(WINAPI* NTQUERYSYSTEMINFORMATION)(
|
| SYSTEM_INFORMATION_CLASS SystemInformationClass,
|
| PVOID SystemInformation,
|
| @@ -32,7 +47,7 @@ typedef NTSTATUS(WINAPI* NTQUERYSYSTEMINFORMATION)(
|
| } // namespace
|
|
|
| SystemMemoryInfoKB::SystemMemoryInfoKB()
|
| - : total(0), free(0), swap_total(0), swap_free(0) {}
|
| + : total(0), free(0), zero(0), available(0), swap_total(0), swap_free(0) {}
|
|
|
| SystemMemoryInfoKB::SystemMemoryInfoKB(const SystemMemoryInfoKB& other) =
|
| default;
|
| @@ -349,17 +364,36 @@ size_t GetPageSize() {
|
| // This function uses the following mapping between MEMORYSTATUSEX and
|
| // SystemMemoryInfoKB:
|
| // ullTotalPhys ==> total
|
| -// ullAvailPhys ==> free
|
| +// ullAvailPhys ==> available
|
| // ullTotalPageFile ==> swap_total
|
| // ullAvailPageFile ==> swap_free
|
| bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo) {
|
| + // Get the function pointer.
|
| + static const NTQUERYSYSTEMINFORMATION query_sys_info =
|
| + reinterpret_cast<NTQUERYSYSTEMINFORMATION>(::GetProcAddress(
|
| + GetModuleHandle(L"ntdll.dll"), "NtQuerySystemInformation"));
|
| +
|
| + if (query_sys_info != nullptr) {
|
| + SYSTEM_MEMORY_LIST_INFORMATION mem_list_info = {};
|
| + ULONG ret_length = 0;
|
| + NTSTATUS status =
|
| + query_sys_info(SystemMemoryListInformation, &mem_list_info,
|
| + sizeof(mem_list_info), &ret_length);
|
| + if (NT_SUCCESS(status)) {
|
| + meminfo->zero = mem_list_info.ZeroPageCount * PAGESIZE_KB;
|
| + meminfo->free = mem_list_info.FreePageCount * PAGESIZE_KB;
|
| + } else {
|
| + NOTREACHED() << "status = " << (ULONG)status << ", ret_length = " << ret_length;
|
| + }
|
| + }
|
| +
|
| MEMORYSTATUSEX mem_status;
|
| mem_status.dwLength = sizeof(mem_status);
|
| if (!::GlobalMemoryStatusEx(&mem_status))
|
| return false;
|
|
|
| meminfo->total = mem_status.ullTotalPhys / 1024;
|
| - meminfo->free = mem_status.ullAvailPhys / 1024;
|
| + meminfo->available = mem_status.ullAvailPhys / 1024;
|
| meminfo->swap_total = mem_status.ullTotalPageFile / 1024;
|
| meminfo->swap_free = mem_status.ullAvailPageFile / 1024;
|
|
|
|
|