| OLD | NEW |
| 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 <mach/task.h> | 7 #include <mach/task.h> |
| 8 | 8 |
| 9 namespace base { | 9 namespace base { |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 return task_info_data.virtual_size; | 37 return task_info_data.virtual_size; |
| 38 } | 38 } |
| 39 | 39 |
| 40 size_t ProcessMetrics::GetWorkingSetSize() const { | 40 size_t ProcessMetrics::GetWorkingSetSize() const { |
| 41 task_basic_info_64 task_info_data; | 41 task_basic_info_64 task_info_data; |
| 42 if (!GetTaskInfo(&task_info_data)) | 42 if (!GetTaskInfo(&task_info_data)) |
| 43 return 0; | 43 return 0; |
| 44 return task_info_data.resident_size; | 44 return task_info_data.resident_size; |
| 45 } | 45 } |
| 46 | 46 |
| 47 size_t GetMaxFds() { |
| 48 static const rlim_t kSystemDefaultMaxFds = 256; |
| 49 rlim_t max_fds; |
| 50 struct rlimit nofile; |
| 51 if (getrlimit(RLIMIT_NOFILE, &nofile)) { |
| 52 // Error case: Take a best guess. |
| 53 max_fds = kSystemDefaultMaxFds; |
| 54 } else { |
| 55 max_fds = nofile.rlim_cur; |
| 56 } |
| 57 |
| 58 if (max_fds > INT_MAX) |
| 59 max_fds = INT_MAX; |
| 60 |
| 61 return static_cast<size_t>(max_fds); |
| 62 } |
| 63 |
| 47 } // namespace base | 64 } // namespace base |
| OLD | NEW |