[go: nahoru, domu]

CrOS - Memory debug widget shows anonymous memory and renderer kills.

Change the status area memory widget to display anonymous memory allocated,
which is a good proxy for "total memory allocated" and what we use in the
UMA histograms (Platform.MemuseAnon[0-5]).  Also display renderer kills, which
will tick up when we run out of memory and the OOM killer starts running.
Refactor GetSystemMemoryInfo to use a struct.

BUG=chromium-os:18969
TEST=manual, turn on memory status widget in about:flags and restart, open some tabs and watch memory consumption increase, use Task Manager / End Process to kill a process and watch the kill count increase

Review URL: http://codereview.chromium.org/7607035

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96423 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/process_util.h b/base/process_util.h
index acaa2d7..b98e266 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -657,11 +657,23 @@
 };
 
 #if defined(OS_LINUX)
+// Data from /proc/meminfo about system-wide memory consumption.
+// Values are in KB.
+struct SystemMemoryInfoKB {
+  SystemMemoryInfoKB() : total(0), free(0), buffers(0), cached(0),
+      active_anon(0), inactive_anon(0), shmem(0) {}
+  int total;
+  int free;
+  int buffers;
+  int cached;
+  int active_anon;
+  int inactive_anon;
+  int shmem;
+};
 // Retrieves data from /proc/meminfo about system-wide memory consumption.
-// Values are in KB. Returns true on success.
-BASE_EXPORT bool GetSystemMemoryInfo(int* total_kb, int* free_kb,
-                                     int* buffers_kb, int* cache_kb,
-                                     int* shmem_kb);
+// Fills in the provided |meminfo| structure. Returns true on success.
+// Exposed for memory debugging widget.
+BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo);
 #endif
 
 // Returns the memory committed by the system in KBytes.