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

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

Issue 2766623002: Revert of Fix free memory calculation. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | base/process/process_metrics.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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/reclaimable/pswpin/pswpout/pgmajfault are available on 267 // inactive_file/dirty/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 "avail_phys" below).
271 struct BASE_EXPORT SystemMemoryInfoKB { 269 struct BASE_EXPORT SystemMemoryInfoKB {
272 SystemMemoryInfoKB(); 270 SystemMemoryInfoKB();
273 SystemMemoryInfoKB(const SystemMemoryInfoKB& other); 271 SystemMemoryInfoKB(const SystemMemoryInfoKB& other);
274 272
275 // Serializes the platform specific fields to value. 273 // Serializes the platform specific fields to value.
276 std::unique_ptr<Value> ToValue() const; 274 std::unique_ptr<Value> ToValue() const;
277 275
278 int total = 0; 276 int total;
277 int free;
279 278
280 #if !defined(OS_WIN) 279 #if defined(OS_LINUX)
281 int free = 0;
282 #endif
283
284 #if defined(OS_WIN)
285 // "This is the amount of physical memory that can be immediately reused
286 // without having to write its contents to disk first. It is the sum of the
287 // size of the standby, free, and zero lists." (MSDN).
288 // Standby: not modified pages of physical ram (file-backed memory) that are
289 // not actively being used.
290 int avail_phys = 0;
291 #endif
292
293 #if defined(OS_LINUX) || defined(OS_ANDROID)
294 // This provides an estimate of available memory as described here: 280 // This provides an estimate of available memory as described here:
295 // https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id= 34e431b0ae398fc54ea69ff85ec700722c9da773 281 // https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id= 34e431b0ae398fc54ea69ff85ec700722c9da773
296 // NOTE: this is ONLY valid in kernels 3.14 and up. Its value will always 282 // NOTE: this is ONLY valid in kernels 3.14 and up. Its value will always
297 // be 0 in earlier kernel versions. 283 // be 0 in earlier kernel versions.
298 // Note: it includes _all_ file-backed memory (active + inactive). 284 int available;
299 int available = 0;
300 #endif 285 #endif
301 286
302 #if !defined(OS_MACOSX) 287 #if !defined(OS_MACOSX)
303 int swap_total = 0; 288 int swap_total;
304 int swap_free = 0; 289 int swap_free;
305 #endif 290 #endif
306 291
307 #if defined(OS_ANDROID) || defined(OS_LINUX) 292 #if defined(OS_ANDROID) || defined(OS_LINUX)
308 int buffers = 0; 293 int buffers;
309 int cached = 0; 294 int cached;
310 int active_anon = 0; 295 int active_anon;
311 int inactive_anon = 0; 296 int inactive_anon;
312 int active_file = 0; 297 int active_file;
313 int inactive_file = 0; 298 int inactive_file;
314 int dirty = 0; 299 int dirty;
315 int reclaimable = 0;
316 300
317 // vmstats data. 301 // vmstats data.
318 unsigned long pswpin = 0; 302 unsigned long pswpin;
319 unsigned long pswpout = 0; 303 unsigned long pswpout;
320 unsigned long pgmajfault = 0; 304 unsigned long pgmajfault;
321 #endif // defined(OS_ANDROID) || defined(OS_LINUX) 305 #endif // defined(OS_ANDROID) || defined(OS_LINUX)
322 306
323 #if defined(OS_CHROMEOS) 307 #if defined(OS_CHROMEOS)
324 int shmem = 0; 308 int shmem;
325 int slab = 0; 309 int slab;
326 // Gem data will be -1 if not supported. 310 // Gem data will be -1 if not supported.
327 int gem_objects = -1; 311 int gem_objects;
328 long long gem_size = -1; 312 long long gem_size;
329 #endif // defined(OS_CHROMEOS) 313 #endif // defined(OS_CHROMEOS)
330
331 #if defined(OS_MACOSX)
332 int speculative = 0;
333 int file_backed = 0;
334 int purgeable = 0;
335 #endif // defined(OS_MACOSX)
336 }; 314 };
337 315
338 // On Linux/Android/Chrome OS, system-wide memory consumption data is parsed 316 // On Linux/Android/Chrome OS, system-wide memory consumption data is parsed
339 // from /proc/meminfo and /proc/vmstat. On Windows/Mac, it is obtained using 317 // from /proc/meminfo and /proc/vmstat. On Windows/Mac, it is obtained using
340 // system API calls. 318 // system API calls.
341 // 319 //
342 // Fills in the provided |meminfo| structure. Returns true on success. 320 // Fills in the provided |meminfo| structure. Returns true on success.
343 // Exposed for memory debugging widget. 321 // Exposed for memory debugging widget.
344 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo); 322 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo);
345 323
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 SystemDiskInfo disk_info_; 430 SystemDiskInfo disk_info_;
453 #endif 431 #endif
454 #if defined(OS_CHROMEOS) 432 #if defined(OS_CHROMEOS)
455 SwapInfo swap_info_; 433 SwapInfo swap_info_;
456 #endif 434 #endif
457 }; 435 };
458 436
459 } // namespace base 437 } // namespace base
460 438
461 #endif // BASE_PROCESS_PROCESS_METRICS_H_ 439 #endif // BASE_PROCESS_PROCESS_METRICS_H_
OLDNEW
« no previous file with comments | « no previous file | base/process/process_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698