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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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/free 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. |
269 struct BASE_EXPORT SystemMemoryInfoKB { | 270 struct BASE_EXPORT SystemMemoryInfoKB { |
270 SystemMemoryInfoKB(); | 271 SystemMemoryInfoKB(); |
271 SystemMemoryInfoKB(const SystemMemoryInfoKB& other); | 272 SystemMemoryInfoKB(const SystemMemoryInfoKB& other); |
272 | 273 |
273 // Serializes the platform specific fields to value. | 274 // Serializes the platform specific fields to value. |
274 std::unique_ptr<Value> ToValue() const; | 275 std::unique_ptr<Value> ToValue() const; |
275 | 276 |
276 int total; | 277 int total; |
| 278 // Note: on Windows this field also includes "zero" memory. |
| 279 // See "Memory Management" and "Memory Performance Information" |
| 280 // articles at MSDN. |
277 int free; | 281 int free; |
278 | 282 |
279 #if defined(OS_LINUX) | 283 #if defined(OS_WIN) |
| 284 // "This is the amount of physical memory that can be immediately reused |
| 285 // without having to write its contents to disk first. It is the sum of the |
| 286 // size of the standby, free, and zero lists." (MSDN). |
| 287 // Standby: not modified pages of physical ram (file-backed memory) that are |
| 288 // not actively being used. |
| 289 // Note: on Windows this field has a bit different meaning from the Linux one |
| 290 // (see below). |
| 291 int available; |
| 292 #endif |
| 293 |
| 294 #if defined(OS_LINUX) || defined(OS_ANDROID) |
280 // This provides an estimate of available memory as described here: | 295 // 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 | 296 // 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 | 297 // NOTE: this is ONLY valid in kernels 3.14 and up. Its value will always |
283 // be 0 in earlier kernel versions. | 298 // be 0 in earlier kernel versions. |
| 299 // Note: on Linux "available" includes _all_ file-backed memory |
| 300 // (active + inactive). It is different from the Windows one (see above). |
284 int available; | 301 int available; |
285 #endif | 302 #endif |
286 | 303 |
287 #if !defined(OS_MACOSX) | 304 #if !defined(OS_MACOSX) |
288 int swap_total; | 305 int swap_total; |
289 int swap_free; | 306 int swap_free; |
290 #endif | 307 #endif |
291 | 308 |
292 #if defined(OS_ANDROID) || defined(OS_LINUX) | 309 #if defined(OS_ANDROID) || defined(OS_LINUX) |
293 int buffers; | 310 int buffers; |
294 int cached; | 311 int cached; |
295 int active_anon; | 312 int active_anon; |
296 int inactive_anon; | 313 int inactive_anon; |
297 int active_file; | 314 int active_file; |
298 int inactive_file; | 315 int inactive_file; |
299 int dirty; | 316 int dirty; |
| 317 int reclaimable; |
300 | 318 |
301 // vmstats data. | 319 // vmstats data. |
302 unsigned long pswpin; | 320 unsigned long pswpin; |
303 unsigned long pswpout; | 321 unsigned long pswpout; |
304 unsigned long pgmajfault; | 322 unsigned long pgmajfault; |
305 #endif // defined(OS_ANDROID) || defined(OS_LINUX) | 323 #endif // defined(OS_ANDROID) || defined(OS_LINUX) |
306 | 324 |
307 #if defined(OS_CHROMEOS) | 325 #if defined(OS_CHROMEOS) |
308 int shmem; | 326 int shmem; |
309 int slab; | 327 int slab; |
310 // Gem data will be -1 if not supported. | 328 // Gem data will be -1 if not supported. |
311 int gem_objects; | 329 int gem_objects; |
312 long long gem_size; | 330 long long gem_size; |
313 #endif // defined(OS_CHROMEOS) | 331 #endif // defined(OS_CHROMEOS) |
| 332 |
| 333 #if defined(OS_MACOSX) || defined(OS_IOS) |
| 334 int speculative; |
| 335 int file_backed; |
| 336 int purgeable; |
| 337 #endif |
314 }; | 338 }; |
315 | 339 |
316 // On Linux/Android/Chrome OS, system-wide memory consumption data is parsed | 340 // 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 | 341 // from /proc/meminfo and /proc/vmstat. On Windows/Mac, it is obtained using |
318 // system API calls. | 342 // system API calls. |
319 // | 343 // |
320 // Fills in the provided |meminfo| structure. Returns true on success. | 344 // Fills in the provided |meminfo| structure. Returns true on success. |
321 // Exposed for memory debugging widget. | 345 // Exposed for memory debugging widget. |
322 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo); | 346 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo); |
323 | 347 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 SystemDiskInfo disk_info_; | 454 SystemDiskInfo disk_info_; |
431 #endif | 455 #endif |
432 #if defined(OS_CHROMEOS) | 456 #if defined(OS_CHROMEOS) |
433 SwapInfo swap_info_; | 457 SwapInfo swap_info_; |
434 #endif | 458 #endif |
435 }; | 459 }; |
436 | 460 |
437 } // namespace base | 461 } // namespace base |
438 | 462 |
439 #endif // BASE_PROCESS_PROCESS_METRICS_H_ | 463 #endif // BASE_PROCESS_PROCESS_METRICS_H_ |
OLD | NEW |