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

Side by Side Diff: base/trace_event/memory_dump_manager.cc

Issue 2695013005: Only enable heap tracking under --enable-heap-profiling=task-profiler. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/trace_event/memory_dump_manager.h" 5 #include "base/trace_event/memory_dump_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/allocator/features.h" 10 #include "base/allocator/features.h"
11 #include "base/atomic_sequence_num.h" 11 #include "base/atomic_sequence_num.h"
12 #include "base/base_switches.h" 12 #include "base/base_switches.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/debug/debugging_flags.h" 15 #include "base/debug/debugging_flags.h"
16 #include "base/debug/stack_trace.h" 16 #include "base/debug/stack_trace.h"
17 #include "base/debug/thread_heap_usage_tracker.h"
17 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
18 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
19 #include "base/threading/thread_task_runner_handle.h" 20 #include "base/threading/thread_task_runner_handle.h"
20 #include "base/trace_event/heap_profiler.h" 21 #include "base/trace_event/heap_profiler.h"
21 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" 22 #include "base/trace_event/heap_profiler_allocation_context_tracker.h"
22 #include "base/trace_event/heap_profiler_event_filter.h" 23 #include "base/trace_event/heap_profiler_event_filter.h"
23 #include "base/trace_event/heap_profiler_stack_frame_deduplicator.h" 24 #include "base/trace_event/heap_profiler_stack_frame_deduplicator.h"
24 #include "base/trace_event/heap_profiler_type_name_deduplicator.h" 25 #include "base/trace_event/heap_profiler_type_name_deduplicator.h"
25 #include "base/trace_event/malloc_dump_provider.h" 26 #include "base/trace_event/malloc_dump_provider.h"
26 #include "base/trace_event/memory_dump_provider.h" 27 #include "base/trace_event/memory_dump_provider.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 (BUILDFLAG(ENABLE_PROFILING) || !defined(NDEBUG)) 193 (BUILDFLAG(ENABLE_PROFILING) || !defined(NDEBUG))
193 // We need frame pointers for native tracing to work, and they are 194 // We need frame pointers for native tracing to work, and they are
194 // enabled in profiling and debug builds. 195 // enabled in profiling and debug builds.
195 AllocationContextTracker::SetCaptureMode( 196 AllocationContextTracker::SetCaptureMode(
196 AllocationContextTracker::CaptureMode::NATIVE_STACK); 197 AllocationContextTracker::CaptureMode::NATIVE_STACK);
197 #else 198 #else
198 CHECK(false) << "'" << profiling_mode << "' mode for " 199 CHECK(false) << "'" << profiling_mode << "' mode for "
199 << switches::kEnableHeapProfiling << " flag is not supported " 200 << switches::kEnableHeapProfiling << " flag is not supported "
200 << "for this platform / build type."; 201 << "for this platform / build type.";
201 #endif 202 #endif
203 } else if (profiling_mode == switches::kEnableHeapProfilingTaskProfiler) {
204 #if BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER)
Primiano Tucci (use gerrit) 2017/02/15 14:18:03 I'd probably put the #if around the "else if", so
Sigurður Ásgeirsson 2017/02/15 15:35:45 Done.
205 // Enable heap tracking, which in turn enables capture of heap usage
206 // tracking in tracked_objects.cc.
207 if (!base::debug::ThreadHeapUsageTracker::IsHeapTrackingEnabled())
208 base::debug::ThreadHeapUsageTracker::EnableHeapTracking();
209 #else
210 CHECK(false) << "'" << profiling_mode << "' mode for "
211 << switches::kEnableHeapProfiling << " flag is not supported "
212 << "for this platform / build type.";
213 #endif
202 } else { 214 } else {
203 CHECK(false) << "Invalid mode '" << profiling_mode << "' for " 215 CHECK(false) << "Invalid mode '" << profiling_mode << "' for "
204 << switches::kEnableHeapProfiling << " flag."; 216 << switches::kEnableHeapProfiling << " flag.";
205 } 217 }
206 218
207 for (auto mdp : dump_providers_) 219 for (auto mdp : dump_providers_)
208 mdp->dump_provider->OnHeapProfilingEnabled(true); 220 mdp->dump_provider->OnHeapProfilingEnabled(true);
209 heap_profiling_enabled_ = true; 221 heap_profiling_enabled_ = true;
210 } 222 }
211 223
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0) 998 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0)
987 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; 999 level_of_detail = MemoryDumpLevelOfDetail::DETAILED;
988 ++periodic_dumps_count_; 1000 ++periodic_dumps_count_;
989 1001
990 MemoryDumpManager::GetInstance()->RequestGlobalDump( 1002 MemoryDumpManager::GetInstance()->RequestGlobalDump(
991 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); 1003 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail);
992 } 1004 }
993 1005
994 } // namespace trace_event 1006 } // namespace trace_event
995 } // namespace base 1007 } // namespace base
OLDNEW
« base/base_switches.cc ('K') | « base/base_switches.cc ('k') | base/tracked_objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698