OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/child_discardable_shared_memory_manager.h" | 5 #include "content/child/child_discardable_shared_memory_manager.h" |
6 | 6 |
| 7 #include <inttypes.h> |
| 8 |
7 #include <algorithm> | 9 #include <algorithm> |
8 #include <utility> | 10 #include <utility> |
9 | 11 |
10 #include "base/atomic_sequence_num.h" | 12 #include "base/atomic_sequence_num.h" |
11 #include "base/bind.h" | 13 #include "base/bind.h" |
12 #include "base/debug/crash_logging.h" | 14 #include "base/debug/crash_logging.h" |
13 #include "base/macros.h" | 15 #include "base/macros.h" |
14 #include "base/memory/discardable_memory.h" | 16 #include "base/memory/discardable_memory.h" |
15 #include "base/memory/discardable_shared_memory.h" | 17 #include "base/memory/discardable_shared_memory.h" |
16 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
17 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
18 #include "base/process/memory.h" | 20 #include "base/process/memory.h" |
19 #include "base/process/process_metrics.h" | 21 #include "base/process/process_metrics.h" |
20 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/stringprintf.h" |
21 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
22 #include "base/trace_event/memory_dump_manager.h" | 25 #include "base/trace_event/memory_dump_manager.h" |
23 #include "base/trace_event/trace_event.h" | 26 #include "base/trace_event/trace_event.h" |
24 #include "content/common/child_process_messages.h" | 27 #include "content/common/child_process_messages.h" |
25 | 28 |
26 namespace content { | 29 namespace content { |
27 namespace { | 30 namespace { |
28 | 31 |
29 // Default allocation size. | 32 // Default allocation size. |
30 const size_t kAllocationSize = 4 * 1024 * 1024; | 33 const size_t kAllocationSize = 4 * 1024 * 1024; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 return base::WrapUnique(new DiscardableMemoryImpl(this, std::move(new_span))); | 213 return base::WrapUnique(new DiscardableMemoryImpl(this, std::move(new_span))); |
211 } | 214 } |
212 | 215 |
213 bool ChildDiscardableSharedMemoryManager::OnMemoryDump( | 216 bool ChildDiscardableSharedMemoryManager::OnMemoryDump( |
214 const base::trace_event::MemoryDumpArgs& args, | 217 const base::trace_event::MemoryDumpArgs& args, |
215 base::trace_event::ProcessMemoryDump* pmd) { | 218 base::trace_event::ProcessMemoryDump* pmd) { |
216 base::AutoLock lock(lock_); | 219 base::AutoLock lock(lock_); |
217 if (args.level_of_detail == | 220 if (args.level_of_detail == |
218 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND) { | 221 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND) { |
219 base::trace_event::MemoryAllocatorDump* total_dump = | 222 base::trace_event::MemoryAllocatorDump* total_dump = |
220 pmd->CreateAllocatorDump("discardable"); | 223 pmd->CreateAllocatorDump( |
| 224 base::StringPrintf("discardable/child_0x%" PRIXPTR, |
| 225 reinterpret_cast<uintptr_t>(this))); |
221 const size_t total_size = heap_.GetSize(); | 226 const size_t total_size = heap_.GetSize(); |
222 const size_t freelist_size = heap_.GetSizeOfFreeLists(); | 227 const size_t freelist_size = heap_.GetSizeOfFreeLists(); |
223 total_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 228 total_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
224 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 229 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
225 total_size - freelist_size); | 230 total_size - freelist_size); |
226 total_dump->AddScalar("freelist_size", | 231 total_dump->AddScalar("freelist_size", |
227 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 232 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
228 freelist_size); | 233 freelist_size); |
229 return true; | 234 return true; |
230 } | 235 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 "discardable-memory-allocated"; | 340 "discardable-memory-allocated"; |
336 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey, | 341 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey, |
337 base::Uint64ToString(new_bytes_total)); | 342 base::Uint64ToString(new_bytes_total)); |
338 | 343 |
339 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free"; | 344 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free"; |
340 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey, | 345 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey, |
341 base::Uint64ToString(new_bytes_free)); | 346 base::Uint64ToString(new_bytes_free)); |
342 } | 347 } |
343 | 348 |
344 } // namespace content | 349 } // namespace content |
OLD | NEW |