Index: chrome/browser/memory/system_memory_stats_recorder_win.cc |
diff --git a/chrome/browser/memory/system_memory_stats_recorder_win.cc b/chrome/browser/memory/system_memory_stats_recorder_win.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..89e62909d0cf661fced245b4b4e860bedac3f528 |
--- /dev/null |
+++ b/chrome/browser/memory/system_memory_stats_recorder_win.cc |
@@ -0,0 +1,83 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/memory/system_memory_stats_recorder.h" |
+ |
+#include <windows.h> |
+ |
+#include "base/metrics/histogram_macros.h" |
+#include "base/process/process_metrics.h" |
+ |
+namespace memory { |
+ |
+// Record a memory size in megabytes, over a potential interval up to 32 GB. |
+#define UMA_HISTOGRAM_LARGE_MEMORY_MB(name, sample) \ |
+ UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 32768, 50) |
+ |
+void RecordMemoryStats(RecordMemoryStatsType type) { |
+ MEMORYSTATUSEX mem_status; |
+ mem_status.dwLength = sizeof(mem_status); |
+ if (!::GlobalMemoryStatusEx(&mem_status)) |
+ return; |
+ |
+ switch (type) { |
+ case RECORD_MEMORY_STATS_TAB_DISCARDED: { |
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.Discard.Win.MemoryLoad", |
+ mem_status.dwMemoryLoad, 0, 100, 101); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Tabs.Discard.Win.TotalPhys", |
+ mem_status.ullTotalPhys); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Tabs.Discard.Win.AvailPhys", |
+ mem_status.ullAvailPhys); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Tabs.Discard.Win.TotalPageFile", |
+ mem_status.Win.ullTotalPageFile); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Tabs.Discard.Win.AvailPageFile", |
+ mem_status.ullAvailPageFile); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Tabs.Discard.Win.TotalVirtual", |
+ mem_status.ullTotalVirtual); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Tabs.Discard.Win.AvailVirtual", |
+ mem_status.ullAvailVirtual); |
+ break; |
+ } |
+ case RECORD_MEMORY_STATS_CONTENTS_OOM_KILLED: { |
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Memory.OOMKill.Win.MemoryLoad", |
+ mem_status.dwMemoryLoad, 0, 100, 101); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Memory.OOMKill.Win.TotalPhys", |
+ mem_status.ullTotalPhys); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Memory.OOMKill.Win.AvailPhys", |
+ mem_status.ullAvailPhys); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Memory.OOMKill.Win.TotalPageFile", |
+ mem_status.ullTotalPageFile); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Memory.OOMKill.Win.AvailPageFile", |
+ mem_status.ullAvailPageFile); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Memory.OOMKill.Win.TotalVirtual", |
+ mem_status.ullTotalVirtual); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Memory.OOMKill.Win.AvailVirtual", |
+ mem_status.ullAvailVirtual); |
+ break; |
+ } |
+ case RECORD_MEMORY_STATS_EXTENSIONS_OOM_KILLED: { |
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Memory.OOMKill.Extensions.Win.MemoryLoad", |
+ mem_status.dwMemoryLoad, 0, 100, 101); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Memory.OOMKill.Extensions.Win.TotalPhys", |
+ mem_status.ullTotalPhys); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB("Memory.OOMKill.Extensions.Win.AvailPhys", |
+ mem_status.ullAvailPhys); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB( |
+ "Memory.OOMKill.Extensions.Win.TotalPageFile", |
+ mem_status.ullTotalPageFile); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB( |
+ "Memory.OOMKill.Extensions.Win.AvailPageFile", |
+ mem_status.ullAvailPageFile); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB( |
+ "Memory.OOMKill.Extensions.Win.TotalVirtual", |
+ mem_status.ullTotalVirtual); |
+ UMA_HISTOGRAM_LARGE_MEMORY_MB( |
+ "Memory.OOMKill.Extensions.Win.AvailVirtual", |
+ mem_status.ullAvailVirtual); |
+ break; |
+ } |
+ } |
+} |
+ |
+} // namespace memory |