Chromium Code Reviews| Index: base/process/process_metrics.h |
| diff --git a/base/process/process_metrics.h b/base/process/process_metrics.h |
| index 2448a715ace9b5eade7f09524561ffcedb666cc3..49e21b1b5a3691c84b5ad417f37f966d1a835dc8 100644 |
| --- a/base/process/process_metrics.h |
| +++ b/base/process/process_metrics.h |
| @@ -261,56 +261,78 @@ BASE_EXPORT void SetFdLimit(unsigned int max_descriptors); |
| // Data about system-wide memory consumption. Values are in KB. Available on |
| // Windows, Mac, Linux, Android and Chrome OS. |
| // |
| -// Total/free memory are available on all platforms that implement |
| +// Total memory are available on all platforms that implement |
| // GetSystemMemoryInfo(). Total/free swap memory are available on all platforms |
| // except on Mac. Buffers/cached/active_anon/inactive_anon/active_file/ |
| -// inactive_file/dirty/pswpin/pswpout/pgmajfault are available on |
| +// inactive_file/dirty/reclaimable/pswpin/pswpout/pgmajfault are available on |
| // Linux/Android/Chrome OS. Shmem/slab/gem_objects/gem_size are Chrome OS only. |
| +// Speculative/file_backed/purgeable are Mac and iOS only. |
| +// Free is absent on Windows (see "available" below). |
| struct BASE_EXPORT SystemMemoryInfoKB { |
| - 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.
|
| - SystemMemoryInfoKB(const SystemMemoryInfoKB& other); |
| - |
| // Serializes the platform specific fields to value. |
| std::unique_ptr<Value> ToValue() const; |
| - int total; |
| - int free; |
| + int total = 0; |
| -#if defined(OS_LINUX) |
| +#if !defined(OS_WIN) |
| + int free = 0; |
| +#endif |
| + |
| +#if defined(OS_WIN) |
| + // "This is the amount of physical memory that can be immediately reused |
| + // without having to write its contents to disk first. It is the sum of the |
| + // size of the standby, free, and zero lists." (MSDN). |
| + // Standby: not modified pages of physical ram (file-backed memory) that are |
| + // not actively being used. |
| + // Note: on Windows this field has a bit different meaning from the Linux one |
| + // (see below). |
| + int available = 0; |
| +#endif |
| + |
| +#if defined(OS_LINUX) || defined(OS_ANDROID) |
| // This provides an estimate of available memory as described here: |
| // https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773 |
| // NOTE: this is ONLY valid in kernels 3.14 and up. Its value will always |
| // be 0 in earlier kernel versions. |
| - int available; |
| + // Note: on Linux "available" includes _all_ file-backed memory |
| + // (active + inactive). It is different from the Windows one (see above). |
| + int available = 0; |
| #endif |
| #if !defined(OS_MACOSX) |
| - int swap_total; |
| - int swap_free; |
| + int swap_total = 0; |
| + int swap_free = 0; |
| #endif |
| #if defined(OS_ANDROID) || defined(OS_LINUX) |
| - int buffers; |
| - int cached; |
| - int active_anon; |
| - int inactive_anon; |
| - int active_file; |
| - int inactive_file; |
| - int dirty; |
| + int buffers = 0; |
| + int cached = 0; |
| + int active_anon = 0; |
| + int inactive_anon = 0; |
| + int active_file = 0; |
| + int inactive_file = 0; |
| + int dirty = 0; |
| + int reclaimable = 0; |
| // vmstats data. |
| - unsigned long pswpin; |
| - unsigned long pswpout; |
| - unsigned long pgmajfault; |
| + unsigned long pswpin = 0; |
| + unsigned long pswpout = 0; |
| + unsigned long pgmajfault = 0; |
| #endif // defined(OS_ANDROID) || defined(OS_LINUX) |
| #if defined(OS_CHROMEOS) |
| - int shmem; |
| - int slab; |
| + int shmem = 0; |
| + int slab = 0; |
| // Gem data will be -1 if not supported. |
| - int gem_objects; |
| - long long gem_size; |
| + int gem_objects = 0; |
| + long long gem_size = 0; |
| #endif // defined(OS_CHROMEOS) |
| + |
| +#if defined(OS_MACOSX) || defined(OS_IOS) |
| + int speculative = 0; |
| + int file_backed = 0; |
| + int purgeable = 0; |
| +#endif |
| }; |
| // On Linux/Android/Chrome OS, system-wide memory consumption data is parsed |