diff options
author | ssid <ssid@chromium.org> | 2015-11-07 04:55:53 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-07 12:56:37 +0000 |
commit | c66aa3f39d85279d8732544bd90b1831911b1826 (patch) | |
tree | 26206a56bfa1f0db96c325fc25d0093ae7074d59 | |
parent | e89e29d26d0f1039d6a2ef76ff997841e2f21daf (diff) | |
download | chromium_src-c66aa3f39d85279d8732544bd90b1831911b1826.zip chromium_src-c66aa3f39d85279d8732544bd90b1831911b1826.tar.gz chromium_src-c66aa3f39d85279d8732544bd90b1831911b1826.tar.bz2 |
[tracing] Display private resident memory in mac
This Cl displays the private memory used by the process on mac in the
tracing.
BUG=542584
Review URL: https://codereview.chromium.org/1419793010
Cr-Commit-Position: refs/heads/master@{#358526}
-rw-r--r-- | base/trace_event/process_memory_totals.cc | 12 | ||||
-rw-r--r-- | base/trace_event/process_memory_totals.h | 20 | ||||
-rw-r--r-- | base/trace_event/process_memory_totals_dump_provider.cc | 7 |
3 files changed, 33 insertions, 6 deletions
diff --git a/base/trace_event/process_memory_totals.cc b/base/trace_event/process_memory_totals.cc index 1270924..de27ab3 100644 --- a/base/trace_event/process_memory_totals.cc +++ b/base/trace_event/process_memory_totals.cc @@ -17,6 +17,8 @@ ProcessMemoryTotals::ProcessMemoryTotals() is_peak_rss_resetable_(false) { } +ProcessMemoryTotals::~ProcessMemoryTotals() {} + void ProcessMemoryTotals::AsValueInto(TracedValue* value) const { value->SetString("resident_set_bytes", StringPrintf("%" PRIx64, resident_set_bytes_)); @@ -25,11 +27,21 @@ void ProcessMemoryTotals::AsValueInto(TracedValue* value) const { StringPrintf("%" PRIx64, peak_resident_set_bytes_)); value->SetBoolean("is_peak_rss_resetable", is_peak_rss_resetable_); } + + for (const auto it : extra_fields_) { + value->SetString(it.first, StringPrintf("%" PRIx64, it.second)); + } } void ProcessMemoryTotals::Clear() { resident_set_bytes_ = 0; } +void ProcessMemoryTotals::SetExtraFieldInBytes(const char* name, + uint64_t value) { + DCHECK_EQ(0u, extra_fields_.count(name)); + extra_fields_[name] = value; +} + } // namespace trace_event } // namespace base diff --git a/base/trace_event/process_memory_totals.h b/base/trace_event/process_memory_totals.h index 1bf8bdc..eb7757c 100644 --- a/base/trace_event/process_memory_totals.h +++ b/base/trace_event/process_memory_totals.h @@ -5,6 +5,8 @@ #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_TOTALS_H_ #define BASE_TRACE_EVENT_PROCESS_MEMORY_TOTALS_H_ +#include <map> + #include "base/base_export.h" #include "base/basictypes.h" @@ -17,6 +19,7 @@ class TracedValue; class BASE_EXPORT ProcessMemoryTotals { public: ProcessMemoryTotals(); + ~ProcessMemoryTotals(); // Called at trace generation time to populate the TracedValue. void AsValueInto(TracedValue* value) const; @@ -24,11 +27,11 @@ class BASE_EXPORT ProcessMemoryTotals { // Clears up all the data collected. void Clear(); - uint64 resident_set_bytes() const { return resident_set_bytes_; } - void set_resident_set_bytes(uint64 value) { resident_set_bytes_ = value; } + uint64_t resident_set_bytes() const { return resident_set_bytes_; } + void set_resident_set_bytes(uint64_t value) { resident_set_bytes_ = value; } - uint64 peak_resident_set_bytes() const { return peak_resident_set_bytes_; } - void set_peak_resident_set_bytes(uint64 value) { + uint64_t peak_resident_set_bytes() const { return peak_resident_set_bytes_; } + void set_peak_resident_set_bytes(uint64_t value) { peak_resident_set_bytes_ = value; } @@ -39,11 +42,16 @@ class BASE_EXPORT ProcessMemoryTotals { bool is_peak_rss_resetable() const { return is_peak_rss_resetable_; } void set_is_peak_rss_resetable(bool value) { is_peak_rss_resetable_ = value; } + void SetExtraFieldInBytes(const char* name, uint64_t value); + private: - uint64 resident_set_bytes_; - uint64 peak_resident_set_bytes_; + uint64_t resident_set_bytes_; + uint64_t peak_resident_set_bytes_; bool is_peak_rss_resetable_; + // Extra metrics for OS-specific statistics. + std::map<const char*, uint64_t> extra_fields_; + DISALLOW_COPY_AND_ASSIGN(ProcessMemoryTotals); }; diff --git a/base/trace_event/process_memory_totals_dump_provider.cc b/base/trace_event/process_memory_totals_dump_provider.cc index a861720..c057deb 100644 --- a/base/trace_event/process_memory_totals_dump_provider.cc +++ b/base/trace_event/process_memory_totals_dump_provider.cc @@ -77,6 +77,13 @@ bool ProcessMemoryTotalsDumpProvider::OnMemoryDump(const MemoryDumpArgs& args, } close(clear_refs_fd); } +#elif defined(OS_MACOSX) + size_t private_bytes; + bool res = process_metrics_->GetMemoryBytes(&private_bytes, + nullptr /* shared_bytes */); + if (res) { + pmd->process_totals()->SetExtraFieldInBytes("private_bytes", private_bytes); + } #endif // defined(OS_LINUX) || defined(OS_ANDROID) #endif // !defined(OS_IOS) |