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

Side by Side Diff: base/process/process_metrics.h

Issue 2558043007: Fix free memory calculation. (Closed)
Patch Set: Fix comment formatting. Created 3 years, 10 months 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
OLDNEW
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
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;
277 int free; 278 int free;
278 279
279 #if defined(OS_LINUX) 280 #if defined(OS_WIN)
281 int zero;
Primiano Tucci (use gerrit) 2017/02/15 11:18:33 what is this?
Michael K. (Yandex Team) 2017/02/17 13:38:47 Done.
282 // On Windows this field has different meaning from the Linux one.
Primiano Tucci (use gerrit) 2017/02/15 11:18:33 nit: add a newline. Also would be nice to explain
Michael K. (Yandex Team) 2017/02/17 13:38:48 Done.
283 int available;
284 #endif
285
286 #if defined(OS_LINUX) || defined(OS_ANDROID)
280 // This provides an estimate of available memory as described here: 287 // 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 288 // 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 289 // NOTE: this is ONLY valid in kernels 3.14 and up. Its value will always
283 // be 0 in earlier kernel versions. 290 // be 0 in earlier kernel versions.
284 int available; 291 int available;
285 #endif 292 #endif
286 293
287 #if !defined(OS_MACOSX) 294 #if !defined(OS_MACOSX)
288 int swap_total; 295 int swap_total;
289 int swap_free; 296 int swap_free;
290 #endif 297 #endif
291 298
292 #if defined(OS_ANDROID) || defined(OS_LINUX) 299 #if defined(OS_ANDROID) || defined(OS_LINUX)
293 int buffers; 300 int buffers;
294 int cached; 301 int cached;
295 int active_anon; 302 int active_anon;
296 int inactive_anon; 303 int inactive_anon;
297 int active_file; 304 int active_file;
298 int inactive_file; 305 int inactive_file;
299 int dirty; 306 int dirty;
307 int reclaimable;
300 308
301 // vmstats data. 309 // vmstats data.
302 unsigned long pswpin; 310 unsigned long pswpin;
303 unsigned long pswpout; 311 unsigned long pswpout;
304 unsigned long pgmajfault; 312 unsigned long pgmajfault;
305 #endif // defined(OS_ANDROID) || defined(OS_LINUX) 313 #endif // defined(OS_ANDROID) || defined(OS_LINUX)
306 314
307 #if defined(OS_CHROMEOS) 315 #if defined(OS_CHROMEOS)
308 int shmem; 316 int shmem;
309 int slab; 317 int slab;
310 // Gem data will be -1 if not supported. 318 // Gem data will be -1 if not supported.
311 int gem_objects; 319 int gem_objects;
312 long long gem_size; 320 long long gem_size;
313 #endif // defined(OS_CHROMEOS) 321 #endif // defined(OS_CHROMEOS)
322
323 #if defined(OS_MACOSX) || defined(OS_IOS)
324 int speculative;
325 int file_backed;
326 int purgeable;
327 #endif
314 }; 328 };
315 329
316 // On Linux/Android/Chrome OS, system-wide memory consumption data is parsed 330 // 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 331 // from /proc/meminfo and /proc/vmstat. On Windows/Mac, it is obtained using
318 // system API calls. 332 // system API calls.
319 // 333 //
320 // Fills in the provided |meminfo| structure. Returns true on success. 334 // Fills in the provided |meminfo| structure. Returns true on success.
321 // Exposed for memory debugging widget. 335 // Exposed for memory debugging widget.
322 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo); 336 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo);
323 337
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 SystemDiskInfo disk_info_; 444 SystemDiskInfo disk_info_;
431 #endif 445 #endif
432 #if defined(OS_CHROMEOS) 446 #if defined(OS_CHROMEOS)
433 SwapInfo swap_info_; 447 SwapInfo swap_info_;
434 #endif 448 #endif
435 }; 449 };
436 450
437 } // namespace base 451 } // namespace base
438 452
439 #endif // BASE_PROCESS_PROCESS_METRICS_H_ 453 #endif // BASE_PROCESS_PROCESS_METRICS_H_
OLDNEW
« no previous file with comments | « no previous file | base/process/process_metrics_ios.cc » ('j') | base/process/process_metrics_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698