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

Side by Side Diff: base/process_util_mac.mm

Issue 371025: More memory stats code cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: multiply uses by 1024 to keep stats consistent with old runs Created 11 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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 5
6 #include "base/process_util.h" 6 #include "base/process_util.h"
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 #include <crt_externs.h> 9 #include <crt_externs.h>
10 #include <mach/mach.h>
10 #include <mach/mach_init.h> 11 #include <mach/mach_init.h>
11 #include <mach/task.h> 12 #include <mach/task.h>
12 #include <spawn.h> 13 #include <spawn.h>
13 #include <sys/sysctl.h> 14 #include <sys/sysctl.h>
14 #include <sys/types.h> 15 #include <sys/types.h>
15 #include <sys/wait.h> 16 #include <sys/wait.h>
16 17
17 #include <string> 18 #include <string>
18 19
19 #include "base/eintr_wrapper.h" 20 #include "base/eintr_wrapper.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 207
207 void ProcessMetrics::GetCommittedKBytes(CommittedKBytes* usage) const { 208 void ProcessMetrics::GetCommittedKBytes(CommittedKBytes* usage) const {
208 } 209 }
209 210
210 bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const { 211 bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const {
211 return false; 212 return false;
212 } 213 }
213 214
214 // ------------------------------------------------------------------------ 215 // ------------------------------------------------------------------------
215 216
217 // Bytes committed by the system.
218 size_t GetSystemCommitCharge() {
219 host_name_port_t host = mach_host_self();
220 mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
221 vm_statistics_data_t data;
222 kern_return_t kr = host_statistics(host, HOST_VM_INFO,
223 reinterpret_cast<host_info_t>(&data),
224 &count);
225 if (kr)
226 LOG(ERROR) << "Failed to fetch host statistics.";
227 return 0;
228
229 vm_size_t page_size;
230 kr = host_page_size(host, &page_size);
231 if (kr)
232 LOG(ERROR) << "Failed to fetch host page size.";
233 return 0;
234
235 return (data.active_count * page_size) / 1024;
236 }
237
216 } // namespace base 238 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698