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 // This file contains routines for gathering resource statistics for processes | 5 // This file contains routines for gathering resource statistics for processes |
6 // running on the system. | 6 // running on the system. |
7 | 7 |
8 #ifndef BASE_PROCESS_PROCESS_METRICS_H_ | 8 #ifndef BASE_PROCESS_PROCESS_METRICS_H_ |
9 #define BASE_PROCESS_PROCESS_METRICS_H_ | 9 #define BASE_PROCESS_PROCESS_METRICS_H_ |
10 | 10 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 // Sets the file descriptor soft limit to |max_descriptors| or the OS hard | 254 // Sets the file descriptor soft limit to |max_descriptors| or the OS hard |
255 // limit, whichever is lower. | 255 // limit, whichever is lower. |
256 BASE_EXPORT void SetFdLimit(unsigned int max_descriptors); | 256 BASE_EXPORT void SetFdLimit(unsigned int max_descriptors); |
257 #endif // defined(OS_POSIX) | 257 #endif // defined(OS_POSIX) |
258 | 258 |
259 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \ | 259 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \ |
260 defined(OS_ANDROID) | 260 defined(OS_ANDROID) |
261 // Data about system-wide memory consumption. Values are in KB. Available on | 261 // Data about system-wide memory consumption. Values are in KB. Available on |
262 // Windows, Mac, Linux, Android and Chrome OS. | 262 // Windows, Mac, Linux, Android and Chrome OS. |
263 // | 263 // |
264 // Total/free memory are available on all platforms that implement | 264 // Total memory are available on all platforms that implement |
265 // GetSystemMemoryInfo(). Total/free swap memory are available on all platforms | 265 // GetSystemMemoryInfo(). Total/free swap memory are available on all platforms |
266 // except on Mac. Buffers/cached/active_anon/inactive_anon/active_file/ | 266 // except on Mac. Buffers/cached/active_anon/inactive_anon/active_file/ |
267 // inactive_file/dirty/pswpin/pswpout/pgmajfault are available on | 267 // inactive_file/dirty/reclaimable/pswpin/pswpout/pgmajfault are available on |
268 // Linux/Android/Chrome OS. Shmem/slab/gem_objects/gem_size are Chrome OS only. | 268 // Linux/Android/Chrome OS. Shmem/slab/gem_objects/gem_size are Chrome OS only. |
269 // Speculative/file_backed/purgeable are Mac and iOS only. | |
270 // Free is absent on Windows (see "available" below). | |
269 struct BASE_EXPORT SystemMemoryInfoKB { | 271 struct BASE_EXPORT SystemMemoryInfoKB { |
270 SystemMemoryInfoKB(); | |
danakj
2017/03/10 17:13:48
You need to keep the out-of-line constructor, it j
Michael K. (Yandex Team)
2017/03/10 18:22:37
Done.
| |
271 SystemMemoryInfoKB(const SystemMemoryInfoKB& other); | |
272 | |
273 // Serializes the platform specific fields to value. | 272 // Serializes the platform specific fields to value. |
274 std::unique_ptr<Value> ToValue() const; | 273 std::unique_ptr<Value> ToValue() const; |
275 | 274 |
276 int total; | 275 int total = 0; |
277 int free; | |
278 | 276 |
279 #if defined(OS_LINUX) | 277 #if !defined(OS_WIN) |
278 int free = 0; | |
279 #endif | |
280 | |
281 #if defined(OS_WIN) | |
282 // "This is the amount of physical memory that can be immediately reused | |
283 // without having to write its contents to disk first. It is the sum of the | |
284 // size of the standby, free, and zero lists." (MSDN). | |
285 // Standby: not modified pages of physical ram (file-backed memory) that are | |
286 // not actively being used. | |
287 // Note: on Windows this field has a bit different meaning from the Linux one | |
288 // (see below). | |
289 int available = 0; | |
290 #endif | |
291 | |
292 #if defined(OS_LINUX) || defined(OS_ANDROID) | |
280 // This provides an estimate of available memory as described here: | 293 // This provides an estimate of available memory as described here: |
281 // https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id= 34e431b0ae398fc54ea69ff85ec700722c9da773 | 294 // https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id= 34e431b0ae398fc54ea69ff85ec700722c9da773 |
282 // NOTE: this is ONLY valid in kernels 3.14 and up. Its value will always | 295 // NOTE: this is ONLY valid in kernels 3.14 and up. Its value will always |
283 // be 0 in earlier kernel versions. | 296 // be 0 in earlier kernel versions. |
284 int available; | 297 // Note: on Linux "available" includes _all_ file-backed memory |
298 // (active + inactive). It is different from the Windows one (see above). | |
299 int available = 0; | |
285 #endif | 300 #endif |
286 | 301 |
287 #if !defined(OS_MACOSX) | 302 #if !defined(OS_MACOSX) |
288 int swap_total; | 303 int swap_total = 0; |
289 int swap_free; | 304 int swap_free = 0; |
290 #endif | 305 #endif |
291 | 306 |
292 #if defined(OS_ANDROID) || defined(OS_LINUX) | 307 #if defined(OS_ANDROID) || defined(OS_LINUX) |
293 int buffers; | 308 int buffers = 0; |
294 int cached; | 309 int cached = 0; |
295 int active_anon; | 310 int active_anon = 0; |
296 int inactive_anon; | 311 int inactive_anon = 0; |
297 int active_file; | 312 int active_file = 0; |
298 int inactive_file; | 313 int inactive_file = 0; |
299 int dirty; | 314 int dirty = 0; |
315 int reclaimable = 0; | |
300 | 316 |
301 // vmstats data. | 317 // vmstats data. |
302 unsigned long pswpin; | 318 unsigned long pswpin = 0; |
303 unsigned long pswpout; | 319 unsigned long pswpout = 0; |
304 unsigned long pgmajfault; | 320 unsigned long pgmajfault = 0; |
305 #endif // defined(OS_ANDROID) || defined(OS_LINUX) | 321 #endif // defined(OS_ANDROID) || defined(OS_LINUX) |
306 | 322 |
307 #if defined(OS_CHROMEOS) | 323 #if defined(OS_CHROMEOS) |
308 int shmem; | 324 int shmem = 0; |
309 int slab; | 325 int slab = 0; |
310 // Gem data will be -1 if not supported. | 326 // Gem data will be -1 if not supported. |
311 int gem_objects; | 327 int gem_objects = 0; |
312 long long gem_size; | 328 long long gem_size = 0; |
313 #endif // defined(OS_CHROMEOS) | 329 #endif // defined(OS_CHROMEOS) |
330 | |
331 #if defined(OS_MACOSX) || defined(OS_IOS) | |
332 int speculative = 0; | |
333 int file_backed = 0; | |
334 int purgeable = 0; | |
335 #endif | |
314 }; | 336 }; |
315 | 337 |
316 // On Linux/Android/Chrome OS, system-wide memory consumption data is parsed | 338 // On Linux/Android/Chrome OS, system-wide memory consumption data is parsed |
317 // from /proc/meminfo and /proc/vmstat. On Windows/Mac, it is obtained using | 339 // from /proc/meminfo and /proc/vmstat. On Windows/Mac, it is obtained using |
318 // system API calls. | 340 // system API calls. |
319 // | 341 // |
320 // Fills in the provided |meminfo| structure. Returns true on success. | 342 // Fills in the provided |meminfo| structure. Returns true on success. |
321 // Exposed for memory debugging widget. | 343 // Exposed for memory debugging widget. |
322 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo); | 344 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo); |
323 | 345 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
430 SystemDiskInfo disk_info_; | 452 SystemDiskInfo disk_info_; |
431 #endif | 453 #endif |
432 #if defined(OS_CHROMEOS) | 454 #if defined(OS_CHROMEOS) |
433 SwapInfo swap_info_; | 455 SwapInfo swap_info_; |
434 #endif | 456 #endif |
435 }; | 457 }; |
436 | 458 |
437 } // namespace base | 459 } // namespace base |
438 | 460 |
439 #endif // BASE_PROCESS_PROCESS_METRICS_H_ | 461 #endif // BASE_PROCESS_PROCESS_METRICS_H_ |
OLD | NEW |