Chromium Code Reviews| 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/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
| 10 #include "base/memory/discardable_memory.h" | 10 #include "base/memory/discardable_memory.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 heap_.MergeIntoFreeLists(leftover.Pass()); | 185 heap_.MergeIntoFreeLists(leftover.Pass()); |
| 186 } | 186 } |
| 187 | 187 |
| 188 MemoryUsageChanged(heap_.GetSize(), heap_.GetSizeOfFreeLists()); | 188 MemoryUsageChanged(heap_.GetSize(), heap_.GetSizeOfFreeLists()); |
| 189 | 189 |
| 190 return make_scoped_ptr(new DiscardableMemoryImpl(this, new_span.Pass())); | 190 return make_scoped_ptr(new DiscardableMemoryImpl(this, new_span.Pass())); |
| 191 } | 191 } |
| 192 | 192 |
| 193 bool ChildDiscardableSharedMemoryManager::OnMemoryDump( | 193 bool ChildDiscardableSharedMemoryManager::OnMemoryDump( |
| 194 base::trace_event::ProcessMemoryDump* pmd) { | 194 base::trace_event::ProcessMemoryDump* pmd) { |
| 195 // Creates a common dump for all the sub-allocated objects from discardable | |
| 196 // memory. To expess any suballocation, the dump providers need to create a | |
| 197 // sub-allocation edge from this node. | |
| 198 // Eg. : pmd->AddSuballocation(skia_dump_guid, | |
| 199 // "discardable/allocated_objects"); | |
| 200 base::trace_event::MemoryAllocatorDump* objects_dump = | |
| 201 pmd->CreateAllocatorDump("discardable/allocated_objects"); | |
|
petrcermak
2015/07/29 11:53:34
Any chance this name could be a constant like http
ssid
2015/07/29 16:20:51
Done.
| |
| 202 base::trace_event::MemoryAllocatorDump* discardable_segments_dump = | |
| 203 pmd->CreateAllocatorDump("discardable/segments"); | |
|
petrcermak
2015/07/29 11:53:34
Could this be a constant?
ssid
2015/07/29 16:20:51
Done.
| |
| 204 | |
| 205 // The discardable memory segments will go under the dump | |
| 206 // "discardable/segments" and any sub-allocations under | |
| 207 // "discardable/allocated_objects" will be owned by it. | |
|
petrcermak
2015/07/29 11:53:34
The relationship is reversed (in the comment).
ssid
2015/07/29 16:20:51
Done.
| |
| 208 pmd->AddOwnershipEdge(objects_dump->guid(), | |
| 209 discardable_segments_dump->guid()); | |
| 210 | |
| 195 base::AutoLock lock(lock_); | 211 base::AutoLock lock(lock_); |
| 196 return heap_.OnMemoryDump(pmd); | 212 return heap_.OnMemoryDump(pmd); |
| 197 } | 213 } |
| 198 | 214 |
| 199 void ChildDiscardableSharedMemoryManager::ReleaseFreeMemory() { | 215 void ChildDiscardableSharedMemoryManager::ReleaseFreeMemory() { |
| 200 base::AutoLock lock(lock_); | 216 base::AutoLock lock(lock_); |
| 201 | 217 |
| 202 size_t heap_size_prior_to_releasing_memory = heap_.GetSize(); | 218 size_t heap_size_prior_to_releasing_memory = heap_.GetSize(); |
| 203 | 219 |
| 204 // Release both purged and free memory. | 220 // Release both purged and free memory. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 "discardable-memory-allocated"; | 306 "discardable-memory-allocated"; |
| 291 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey, | 307 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey, |
| 292 base::Uint64ToString(new_bytes_total)); | 308 base::Uint64ToString(new_bytes_total)); |
| 293 | 309 |
| 294 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free"; | 310 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free"; |
| 295 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey, | 311 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey, |
| 296 base::Uint64ToString(new_bytes_free)); | 312 base::Uint64ToString(new_bytes_free)); |
| 297 } | 313 } |
| 298 | 314 |
| 299 } // namespace content | 315 } // namespace content |
| OLD | NEW |