| OLD | NEW |
| 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 | 8 |
| 9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 33 #include "base/trace_event/winheap_dump_provider_win.h" | 33 #include "base/trace_event/winheap_dump_provider_win.h" |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 namespace base { | 36 namespace base { |
| 37 namespace trace_event { | 37 namespace trace_event { |
| 38 | 38 |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| 41 // TODO(primiano): this should be smarter and should do something similar to | |
| 42 // trace event synthetic delays. | |
| 43 const char kTraceCategory[] = TRACE_DISABLED_BY_DEFAULT("memory-infra"); | |
| 44 | |
| 45 // Throttle mmaps at a rate of once every kHeavyMmapsDumpsRate standard dumps. | 41 // Throttle mmaps at a rate of once every kHeavyMmapsDumpsRate standard dumps. |
| 46 const int kHeavyDumpsRate = 8; // 250 ms * 8 = 2000 ms. | 42 const int kHeavyDumpsRate = 8; // 250 ms * 8 = 2000 ms. |
| 47 const int kDumpIntervalMs = 250; | 43 const int kDumpIntervalMs = 250; |
| 48 const int kTraceEventNumArgs = 1; | 44 const int kTraceEventNumArgs = 1; |
| 49 const char* kTraceEventArgNames[] = {"dumps"}; | 45 const char* kTraceEventArgNames[] = {"dumps"}; |
| 50 const unsigned char kTraceEventArgTypes[] = {TRACE_VALUE_TYPE_CONVERTABLE}; | 46 const unsigned char kTraceEventArgTypes[] = {TRACE_VALUE_TYPE_CONVERTABLE}; |
| 51 | 47 |
| 52 StaticAtomicSequenceNumber g_next_guid; | 48 StaticAtomicSequenceNumber g_next_guid; |
| 53 uint32 g_periodic_dumps_count = 0; | 49 uint32 g_periodic_dumps_count = 0; |
| 54 MemoryDumpManager* g_instance_for_testing = nullptr; | 50 MemoryDumpManager* g_instance_for_testing = nullptr; |
| 55 | 51 |
| 56 void RequestPeriodicGlobalDump() { | 52 void RequestPeriodicGlobalDump() { |
| 57 MemoryDumpArgs::LevelOfDetail dump_level_of_detail = | 53 MemoryDumpArgs::LevelOfDetail dump_level_of_detail = |
| 58 g_periodic_dumps_count == 0 ? MemoryDumpArgs::LevelOfDetail::HIGH | 54 g_periodic_dumps_count == 0 ? MemoryDumpArgs::LevelOfDetail::HIGH |
| 59 : MemoryDumpArgs::LevelOfDetail::LOW; | 55 : MemoryDumpArgs::LevelOfDetail::LOW; |
| 60 if (++g_periodic_dumps_count == kHeavyDumpsRate) | 56 if (++g_periodic_dumps_count == kHeavyDumpsRate) |
| 61 g_periodic_dumps_count = 0; | 57 g_periodic_dumps_count = 0; |
| 62 | 58 |
| 63 MemoryDumpArgs dump_args = {dump_level_of_detail}; | 59 MemoryDumpArgs dump_args = {dump_level_of_detail}; |
| 64 MemoryDumpManager::GetInstance()->RequestGlobalDump( | 60 MemoryDumpManager::GetInstance()->RequestGlobalDump( |
| 65 MemoryDumpType::PERIODIC_INTERVAL, dump_args); | 61 MemoryDumpType::PERIODIC_INTERVAL, dump_args); |
| 66 } | 62 } |
| 67 | 63 |
| 68 } // namespace | 64 } // namespace |
| 69 | 65 |
| 70 // static | 66 // static |
| 71 const char* const MemoryDumpManager::kTraceCategoryForTesting = kTraceCategory; | 67 const char* const MemoryDumpManager::kTraceCategory = |
| 68 TRACE_DISABLED_BY_DEFAULT("memory-infra"); |
| 72 | 69 |
| 73 // static | 70 // static |
| 74 const int MemoryDumpManager::kMaxConsecutiveFailuresCount = 3; | 71 const int MemoryDumpManager::kMaxConsecutiveFailuresCount = 3; |
| 75 | 72 |
| 76 // static | 73 // static |
| 77 const uint64 MemoryDumpManager::kInvalidTracingProcessId = 0; | 74 const uint64 MemoryDumpManager::kInvalidTracingProcessId = 0; |
| 78 | 75 |
| 79 // static | 76 // static |
| 80 MemoryDumpManager* MemoryDumpManager::GetInstance() { | 77 MemoryDumpManager* MemoryDumpManager::GetInstance() { |
| 81 if (g_instance_for_testing) | 78 if (g_instance_for_testing) |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 next_dump_provider(next_dump_provider), | 473 next_dump_provider(next_dump_provider), |
| 477 callback(callback), | 474 callback(callback), |
| 478 task_runner(MessageLoop::current()->task_runner()) { | 475 task_runner(MessageLoop::current()->task_runner()) { |
| 479 } | 476 } |
| 480 | 477 |
| 481 MemoryDumpManager::ProcessMemoryDumpAsyncState::~ProcessMemoryDumpAsyncState() { | 478 MemoryDumpManager::ProcessMemoryDumpAsyncState::~ProcessMemoryDumpAsyncState() { |
| 482 } | 479 } |
| 483 | 480 |
| 484 } // namespace trace_event | 481 } // namespace trace_event |
| 485 } // namespace base | 482 } // namespace base |
| OLD | NEW |