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 "base/debug/crash_logging.h" | 7 #include "base/debug/crash_logging.h" |
8 #include "base/memory/discardable_shared_memory.h" | 8 #include "base/memory/discardable_shared_memory.h" |
| 9 #include "base/metrics/histogram.h" |
9 #include "base/process/process_metrics.h" | 10 #include "base/process/process_metrics.h" |
10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
11 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
12 #include "content/common/child_process_messages.h" | 13 #include "content/common/child_process_messages.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 namespace { | 16 namespace { |
16 | 17 |
17 // Default allocation size. | 18 // Default allocation size. |
18 #if defined(OS_ANDROID) | 19 #if defined(OS_ANDROID) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 BytesAllocatedChanged(0); | 60 BytesAllocatedChanged(0); |
60 } | 61 } |
61 | 62 |
62 scoped_ptr<base::DiscardableMemoryShmemChunk> | 63 scoped_ptr<base::DiscardableMemoryShmemChunk> |
63 ChildDiscardableSharedMemoryManager::AllocateLockedDiscardableMemory( | 64 ChildDiscardableSharedMemoryManager::AllocateLockedDiscardableMemory( |
64 size_t size) { | 65 size_t size) { |
65 base::AutoLock lock(lock_); | 66 base::AutoLock lock(lock_); |
66 | 67 |
67 DCHECK_NE(size, 0u); | 68 DCHECK_NE(size, 0u); |
68 | 69 |
| 70 UMA_HISTOGRAM_CUSTOM_COUNTS("Memory.DiscardableAllocationSize", |
| 71 size / 1024, // In KB |
| 72 1, |
| 73 4 * 1024 * 1024, // 4 GB |
| 74 50); |
| 75 |
69 // Round up to multiple of page size. | 76 // Round up to multiple of page size. |
70 size_t pages = (size + base::GetPageSize() - 1) / base::GetPageSize(); | 77 size_t pages = (size + base::GetPageSize() - 1) / base::GetPageSize(); |
71 | 78 |
72 for (;;) { | 79 for (;;) { |
73 // Search free list for available space. | 80 // Search free list for available space. |
74 scoped_ptr<DiscardableSharedMemoryHeap::Span> free_span = | 81 scoped_ptr<DiscardableSharedMemoryHeap::Span> free_span = |
75 heap_.SearchFreeList(pages); | 82 heap_.SearchFreeList(pages); |
76 if (!free_span.get()) | 83 if (!free_span.get()) |
77 break; | 84 break; |
78 | 85 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 size_t new_bytes_allocated) const { | 234 size_t new_bytes_allocated) const { |
228 TRACE_COUNTER_ID1("renderer", "DiscardableMemoryUsage", this, | 235 TRACE_COUNTER_ID1("renderer", "DiscardableMemoryUsage", this, |
229 new_bytes_allocated); | 236 new_bytes_allocated); |
230 | 237 |
231 static const char kDiscardableMemoryUsageKey[] = "dm-usage"; | 238 static const char kDiscardableMemoryUsageKey[] = "dm-usage"; |
232 base::debug::SetCrashKeyValue(kDiscardableMemoryUsageKey, | 239 base::debug::SetCrashKeyValue(kDiscardableMemoryUsageKey, |
233 base::Uint64ToString(new_bytes_allocated)); | 240 base::Uint64ToString(new_bytes_allocated)); |
234 } | 241 } |
235 | 242 |
236 } // namespace content | 243 } // namespace content |
OLD | NEW |