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

Side by Side Diff: base/process/process_metrics_win.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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/process/process_metrics.h" 5 #include "base/process/process_metrics.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <psapi.h> 8 #include <psapi.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // Returns the peak working set size, in bytes. 74 // Returns the peak working set size, in bytes.
75 size_t ProcessMetrics::GetPeakWorkingSetSize() const { 75 size_t ProcessMetrics::GetPeakWorkingSetSize() const {
76 PROCESS_MEMORY_COUNTERS pmc; 76 PROCESS_MEMORY_COUNTERS pmc;
77 if (GetProcessMemoryInfo(process_, &pmc, sizeof(pmc))) { 77 if (GetProcessMemoryInfo(process_, &pmc, sizeof(pmc))) {
78 return pmc.PeakWorkingSetSize; 78 return pmc.PeakWorkingSetSize;
79 } 79 }
80 return 0; 80 return 0;
81 } 81 }
82 82
83 bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, 83 bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes,
84 size_t* shared_bytes) { 84 size_t* shared_bytes) const {
85 // PROCESS_MEMORY_COUNTERS_EX is not supported until XP SP2. 85 // PROCESS_MEMORY_COUNTERS_EX is not supported until XP SP2.
86 // GetProcessMemoryInfo() will simply fail on prior OS. So the requested 86 // GetProcessMemoryInfo() will simply fail on prior OS. So the requested
87 // information is simply not available. Hence, we will return 0 on unsupported 87 // information is simply not available. Hence, we will return 0 on unsupported
88 // OSes. Unlike most Win32 API, we don't need to initialize the "cb" member. 88 // OSes. Unlike most Win32 API, we don't need to initialize the "cb" member.
89 PROCESS_MEMORY_COUNTERS_EX pmcx; 89 PROCESS_MEMORY_COUNTERS_EX pmcx;
90 if (private_bytes && 90 if (private_bytes &&
91 GetProcessMemoryInfo(process_, 91 GetProcessMemoryInfo(process_,
92 reinterpret_cast<PROCESS_MEMORY_COUNTERS*>(&pmcx), 92 reinterpret_cast<PROCESS_MEMORY_COUNTERS*>(&pmcx),
93 sizeof(pmcx))) { 93 sizeof(pmcx))) {
94 *private_bytes = pmcx.PrivateUsage; 94 *private_bytes = pmcx.PrivateUsage;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 360
361 meminfo->total = mem_status.ullTotalPhys / 1024; 361 meminfo->total = mem_status.ullTotalPhys / 1024;
362 meminfo->free = mem_status.ullAvailPhys / 1024; 362 meminfo->free = mem_status.ullAvailPhys / 1024;
363 meminfo->swap_total = mem_status.ullTotalPageFile / 1024; 363 meminfo->swap_total = mem_status.ullTotalPageFile / 1024;
364 meminfo->swap_free = mem_status.ullAvailPageFile / 1024; 364 meminfo->swap_free = mem_status.ullAvailPageFile / 1024;
365 365
366 return true; 366 return true;
367 } 367 }
368 368
369 } // namespace base 369 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_metrics_openbsd.cc ('k') | chrome/browser/task_manager/sampling/task_group_sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698