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..175881d1648681393cb6a1ce87896e9a5c4ddd88 100644 |
| --- a/base/process/process_metrics_mac.cc |
| +++ b/base/process/process_metrics_mac.cc |
| @@ -110,10 +110,11 @@ size_t ProcessMetrics::GetPeakPagefileUsage() const { |
| } |
| size_t ProcessMetrics::GetWorkingSetSize() const { |
| - task_basic_info_64 task_info_data; |
| - if (!GetTaskInfo(TaskForPid(process_), &task_info_data)) |
| + size_t private_bytes = 0; |
| + size_t shared_bytes = 0; |
| + if (!GetMemoryBytes(&private_bytes, &shared_bytes)) |
| return 0; |
| - return task_info_data.resident_size; |
| + return private_bytes + shared_bytes; |
|
Mark Mentovai
2017/03/13 21:05:08
Call the 3-arg GetMemoryBytes() and return the thi
erikchen
2017/03/13 21:19:04
Done.
|
| } |
| size_t ProcessMetrics::GetPeakWorkingSetSize() const { |
| @@ -124,7 +125,7 @@ size_t ProcessMetrics::GetPeakWorkingSetSize() const { |
| // private_bytes is the size of private resident memory. |
| // shared_bytes is the size of shared resident memory. |
| bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, |
| - size_t* shared_bytes) { |
| + size_t* shared_bytes) const { |
| size_t private_pages_count = 0; |
| size_t shared_pages_count = 0; |
| @@ -189,6 +190,7 @@ bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, |
| info.share_mode = SM_PRIVATE; |
| switch (info.share_mode) { |
| + case SM_LARGE_PAGE: |
| case SM_PRIVATE: |
| private_pages_count += info.private_pages_resident; |
| private_pages_count += info.shared_pages_resident; |
| @@ -197,6 +199,9 @@ bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, |
| private_pages_count += info.private_pages_resident; |
| // Fall through |
| case SM_SHARED: |
| + case SM_PRIVATE_ALIASED: |
| + case SM_TRUESHARED: |
| + case SM_SHARED_ALIASED: |
| if (seen_objects.count(info.obj_id) == 0) { |
| // Only count the first reference to this region. |
| seen_objects.insert(info.obj_id); |
| @@ -246,6 +251,15 @@ bool ProcessMetrics::GetCommittedAndWorkingSetKBytes( |
| return true; |
| } |
| +bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, |
| + size_t* shared_bytes, |
| + size_t* resident_bytes) const { |
| + if (!GetMemoryBytes(private_bytes, shared_bytes)) |
| + return false; |
| + *resident_bytes = *private_bytes + *shared_bytes; |
| + return true; |
| +} |
| + |
| #define TIME_VALUE_TO_TIMEVAL(a, r) do { \ |
| (r)->tv_sec = (a)->seconds; \ |
| (r)->tv_usec = (a)->microseconds; \ |