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

Unified Diff: base/trace_event/trace_config.cc

Issue 1911643002: Add configurable limit to allocations in heap profiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 4 years, 8 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
Index: base/trace_event/trace_config.cc
diff --git a/base/trace_event/trace_config.cc b/base/trace_event/trace_config.cc
index e9e5a099893377e844be716845b0bbcfe90a2639..7cde06f779a8c328b61c6522419b95bd4d83c938 100644
--- a/base/trace_event/trace_config.cc
+++ b/base/trace_event/trace_config.cc
@@ -50,6 +50,7 @@ const char kMemoryDumpConfigParam[] = "memory_dump_config";
const char kTriggersParam[] = "triggers";
const char kPeriodicIntervalParam[] = "periodic_interval_ms";
const char kModeParam[] = "mode";
+const char kMinAllocationSize[] = "min_allocation_size_bytes";
// Default configuration of memory dumps.
const TraceConfig::MemoryDumpTriggerConfig kDefaultHeavyMemoryDumpTrigger = {
@@ -123,6 +124,7 @@ TraceConfig::TraceConfig(const TraceConfig& tc)
enable_systrace_(tc.enable_systrace_),
enable_argument_filter_(tc.enable_argument_filter_),
memory_dump_config_(tc.memory_dump_config_),
+ min_allocation_size_bytes_(tc.min_allocation_size_bytes_),
included_categories_(tc.included_categories_),
disabled_categories_(tc.disabled_categories_),
excluded_categories_(tc.excluded_categories_),
@@ -140,6 +142,7 @@ TraceConfig& TraceConfig::operator=(const TraceConfig& rhs) {
enable_systrace_ = rhs.enable_systrace_;
enable_argument_filter_ = rhs.enable_argument_filter_;
memory_dump_config_ = rhs.memory_dump_config_;
+ min_allocation_size_bytes_ = rhs.min_allocation_size_bytes_;
included_categories_ = rhs.included_categories_;
disabled_categories_ = rhs.disabled_categories_;
excluded_categories_ = rhs.excluded_categories_;
@@ -516,12 +519,22 @@ void TraceConfig::SetMemoryDumpConfig(
StringToMemoryDumpLevelOfDetail(level_of_detail_str);
memory_dump_config_.push_back(dump_config);
}
+
+ int min_size_bytes = 0;
+ if (memory_dump_config.GetInteger(kMinAllocationSize, &min_size_bytes)
+ && min_size_bytes >= 0) {
+ min_allocation_size_bytes_ = static_cast<size_t>(min_size_bytes);
+ } else {
+ min_allocation_size_bytes_ = kDefaultMinAllocationSizeBytes;
+ }
+
}
void TraceConfig::SetDefaultMemoryDumpConfig() {
memory_dump_config_.clear();
memory_dump_config_.push_back(kDefaultHeavyMemoryDumpTrigger);
memory_dump_config_.push_back(kDefaultLightMemoryDumpTrigger);
+ min_allocation_size_bytes_ = kDefaultMinAllocationSizeBytes;
}
void TraceConfig::ToDict(base::DictionaryValue& dict) const {
@@ -582,6 +595,10 @@ void TraceConfig::ToDict(base::DictionaryValue& dict) const {
// Empty triggers will still be specified explicitly since it means that
// the periodic dumps are not enabled.
memory_dump_config->Set(kTriggersParam, std::move(triggers_list));
+
+ if (min_allocation_size_bytes_ != kDefaultMinAllocationSizeBytes)
+ memory_dump_config->SetInteger(kMinAllocationSize,
+ min_allocation_size_bytes_);
dict.Set(kMemoryDumpConfigParam, std::move(memory_dump_config));
}
}

Powered by Google App Engine
This is Rietveld 408576698