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

Unified Diff: chrome/browser/memory/system_memory_stats_recorder_win.cc

Issue 1214803006: [Memory] Add system_memory_stats_recorder_win.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/chrome_browser.gypi » ('j') | tools/metrics/histograms/histograms.xml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | chrome/chrome_browser.gypi » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698