diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 18:58:57 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 18:58:57 +0000 |
commit | 4306df76b739842d6b8942b52549023dc7221938 (patch) | |
tree | 3dd9ba98a6abb807c77907fb8bb3d76c2b21735d /chrome/browser/memory_details.cc | |
parent | e6a638e12a4c95afc24812eeb0208e350206a0a0 (diff) | |
download | chromium_src-4306df76b739842d6b8942b52549023dc7221938.zip chromium_src-4306df76b739842d6b8942b52549023dc7221938.tar.gz chromium_src-4306df76b739842d6b8942b52549023dc7221938.tar.bz2 |
cros: Log per-process memory use on low memory events
We're seeing a lot of tab reloads caused by the tab discarder, but we're not sure yet where the memory is going. Dump the per-process private and shared memory use (same as the Task Manager columns) for Chrome processes when we hit low memory, such that we can see it in the system logs when users send us a feedback report. This adds tens of milliseconds to the delay between the low memory signal and the tab discard starting, but that isn't significant as we allow 750 ms for the discard to happen and the memory stats are collected asynchronously off of the UI thread.
Also refactor when we log UMA memory statistics - we used to do it every time we collected memory details, but with this change we need to be able to collect the details and skip additional UMA stats.
BUG=124038
TEST=browser_tests OomPriorityManagerTest, manual inspection of logs after triggering tab discard with about:discards
Review URL: http://codereview.chromium.org/10151005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133232 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/memory_details.cc')
-rw-r--r-- | chrome/browser/memory_details.cc | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc index 64d3a87..2fab74b 100644 --- a/chrome/browser/memory_details.cc +++ b/chrome/browser/memory_details.cc @@ -9,6 +9,7 @@ #include "base/metrics/histogram.h" #include "base/process_util.h" #include "base/string_util.h" +#include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_service.h" @@ -35,6 +36,7 @@ #include "content/public/browser/zygote_host_linux.h" #endif +using base::StringPrintf; using content::BrowserChildProcessHostIterator; using content::BrowserThread; using content::NavigationEntry; @@ -115,10 +117,11 @@ ProcessData& ProcessData::operator=(const ProcessData& rhs) { // one task run for that long on the UI or IO threads. So, we run the // expensive parts of this operation over on the file thread. // -void MemoryDetails::StartFetch() { +void MemoryDetails::StartFetch(UserMetricsMode user_metrics_mode) { // This might get called from the UI or FILE threads, but should not be // getting called from the IO thread. DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); + user_metrics_mode_ = user_metrics_mode; // In order to process this request, we need to use the plugin information. // However, plugin process information is only available from the IO thread. @@ -129,6 +132,33 @@ void MemoryDetails::StartFetch() { MemoryDetails::~MemoryDetails() {} +std::string MemoryDetails::ToLogString() { + std::string log; + log.reserve(4096); + const ProcessData& chrome = *ChromeBrowser(); + for (ProcessMemoryInformationList::const_iterator iter1 = + chrome.processes.begin(); + iter1 != chrome.processes.end(); ++iter1) { + log += ProcessMemoryInformation::GetFullTypeNameInEnglish( + iter1->type, iter1->renderer_type); + if (!iter1->titles.empty()) { + log += " ["; + for (std::vector<string16>::const_iterator iter2 = + iter1->titles.begin(); + iter2 != iter1->titles.end(); ++iter2) { + if (iter2 != iter1->titles.begin()) + log += "|"; + log += UTF16ToUTF8(*iter2); + } + log += "]"; + } + log += StringPrintf(" %d MB private, %d MB shared\n", + static_cast<int>(iter1->working_set.priv) / 1024, + static_cast<int>(iter1->working_set.shared) / 1024); + } + return log; +} + void MemoryDetails::CollectChildInfoOnIOThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); @@ -322,7 +352,8 @@ void MemoryDetails::CollectChildInfoOnUIThread() { } } - UpdateHistograms(); + if (user_metrics_mode_ == UPDATE_USER_METRICS) + UpdateHistograms(); OnDetailsAvailable(); } |