Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: base/process/process_metrics_mac.cc

Issue 2740423002: mac: Fix calulation for number of resident pages in a process. (Closed)
Patch Set: comments from mark. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process/process_metrics_linux.cc ('k') | base/process/process_metrics_openbsd.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..84bf3eaa164f87301f49a1b1ffb66cfa23b9c7d5 100644
--- a/base/process/process_metrics_mac.cc
+++ b/base/process/process_metrics_mac.cc
@@ -110,10 +110,12 @@ 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;
+ size_t resident_bytes = 0;
+ if (!GetMemoryBytes(&private_bytes, &shared_bytes, &resident_bytes))
return 0;
- return task_info_data.resident_size;
+ return resident_bytes;
}
size_t ProcessMetrics::GetPeakWorkingSetSize() const {
@@ -124,7 +126,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 +191,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 +200,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 +252,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; \
« no previous file with comments | « base/process/process_metrics_linux.cc ('k') | base/process/process_metrics_openbsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698