Chromium Code Reviews| Index: base/process/process_metrics_mac.cc |
| diff --git a/base/process/process_metrics_mac.cc b/base/process/process_metrics_mac.cc |
| index a3c2d6a14aa6acbd2e07e9afd6a55a836bbb3f10..74c9c0aa1f795d2ab1b971149a9c76a89d1c75c0 100644 |
| --- a/base/process/process_metrics_mac.cc |
| +++ b/base/process/process_metrics_mac.cc |
| @@ -80,11 +80,6 @@ bool IsAddressInSharedRegion(mach_vm_address_t addr, cpu_type_t type) { |
| } // namespace |
| -SystemMemoryInfoKB::SystemMemoryInfoKB() : total(0), free(0) {} |
| - |
| -SystemMemoryInfoKB::SystemMemoryInfoKB(const SystemMemoryInfoKB& other) = |
| - default; |
| - |
| // Getting a mach task from a pid for another process requires permissions in |
| // general, so there doesn't really seem to be a way to do these (and spinning |
| // up ps to fetch each stats seems dangerous to put in a base api for anyone to |
| @@ -377,7 +372,6 @@ size_t GetSystemCommitCharge() { |
| return (data.active_count * PAGE_SIZE) / 1024; |
| } |
| -// On Mac, We only get total memory and free memory from the system. |
| bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo) { |
| struct host_basic_info hostinfo; |
| mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; |
| @@ -390,17 +384,24 @@ bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo) { |
| DCHECK_EQ(HOST_BASIC_INFO_COUNT, count); |
| meminfo->total = static_cast<int>(hostinfo.max_mem / 1024); |
| - vm_statistics_data_t vm_info; |
| - count = HOST_VM_INFO_COUNT; |
| + vm_statistics64_data_t vm_info; |
| + count = HOST_VM_INFO64_COUNT; |
| - if (host_statistics(host.get(), HOST_VM_INFO, |
| - reinterpret_cast<host_info_t>(&vm_info), |
| - &count) != KERN_SUCCESS) { |
| + if (host_statistics64(host.get(), HOST_VM_INFO64, |
| + reinterpret_cast<host_info64_t>(&vm_info), |
| + &count) != KERN_SUCCESS) { |
| return false; |
| } |
| + DCHECK_EQ(HOST_VM_INFO64_COUNT, count); |
| meminfo->free = static_cast<int>( |
| (vm_info.free_count - vm_info.speculative_count) * PAGE_SIZE / 1024); |
| + meminfo->speculative = |
| + static_cast<int>(vm_info.speculative_count * PAGE_SIZE / 1024); |
|
danakj
2017/03/10 17:13:48
should these fields on meminfo not be int64? if no
Michael K. (Yandex Team)
2017/03/10 18:22:37
meminfo contains data in kilobytes. So it is hard
|
| + meminfo->file_backed = |
| + static_cast<int>(vm_info.external_page_count * PAGE_SIZE / 1024); |
| + meminfo->purgeable = |
| + static_cast<int>(vm_info.purgeable_count * PAGE_SIZE / 1024); |
| return true; |
| } |