| 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 "platform/heap/BlinkGCMemoryDumpProvider.h" | 5 #include "platform/heap/BlinkGCMemoryDumpProvider.h" |
| 6 | 6 |
| 7 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" | 7 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
| 8 #include "base/trace_event/heap_profiler_allocation_register.h" | 8 #include "base/trace_event/heap_profiler_allocation_register.h" |
| 9 #include "base/trace_event/trace_event_memory_overhead.h" | 9 #include "base/trace_event/trace_event_memory_overhead.h" |
| 10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| 11 #include "platform/web_process_memory_dump_impl.h" | 11 #include "platform/web_process_memory_dump_impl.h" |
| 12 #include "public/platform/Platform.h" | 12 #include "public/platform/Platform.h" |
| 13 #include "public/platform/WebMemoryAllocatorDump.h" | 13 #include "public/platform/WebMemoryAllocatorDump.h" |
| 14 #include "wtf/StdLibExtras.h" | 14 #include "wtf/StdLibExtras.h" |
| 15 #include "wtf/Threading.h" | 15 #include "wtf/Threading.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 void dumpMemoryTotals(blink::WebProcessMemoryDump* memoryDump) | 20 void dumpMemoryTotals(blink::WebProcessMemoryDump* memoryDump) |
| 21 { | 21 { |
| 22 String dumpName = String::format("blink_gc"); | 22 String dumpName = String::format("blink_gc"); |
| 23 WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDum
p(dumpName); | 23 WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDum
p(dumpName); |
| 24 allocatorDump->addScalar("size", "bytes", Heap::allocatedSpace()); | 24 allocatorDump->addScalar("size", "bytes", ProcessHeap::totalAllocatedSpace()
); |
| 25 | 25 |
| 26 dumpName.append("/allocated_objects"); | 26 dumpName.append("/allocated_objects"); |
| 27 WebMemoryAllocatorDump* objectsDump = memoryDump->createMemoryAllocatorDump(
dumpName); | 27 WebMemoryAllocatorDump* objectsDump = memoryDump->createMemoryAllocatorDump(
dumpName); |
| 28 | 28 |
| 29 // Heap::markedObjectSize() can be underestimated if we're still in the | 29 // Heap::markedObjectSize() can be underestimated if we're still in the |
| 30 // process of lazy sweeping. | 30 // process of lazy sweeping. |
| 31 objectsDump->addScalar("size", "bytes", Heap::allocatedObjectSize() + Heap::
markedObjectSize()); | 31 objectsDump->addScalar("size", "bytes", ProcessHeap::totalAllocatedObjectSiz
e() + ProcessHeap::totalMarkedObjectSize()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void reportAllocation(Address address, size_t size, const char* typeName) | 34 void reportAllocation(Address address, size_t size, const char* typeName) |
| 35 { | 35 { |
| 36 BlinkGCMemoryDumpProvider::instance()->insert(address, size, typeName); | 36 BlinkGCMemoryDumpProvider::instance()->insert(address, size, typeName); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void reportFree(Address address) | 39 void reportFree(Address address) |
| 40 { | 40 { |
| 41 BlinkGCMemoryDumpProvider::instance()->remove(address); | 41 BlinkGCMemoryDumpProvider::instance()->remove(address); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 125 } |
| 126 | 126 |
| 127 void BlinkGCMemoryDumpProvider::remove(Address address) | 127 void BlinkGCMemoryDumpProvider::remove(Address address) |
| 128 { | 128 { |
| 129 MutexLocker locker(m_allocationRegisterMutex); | 129 MutexLocker locker(m_allocationRegisterMutex); |
| 130 if (m_allocationRegister) | 130 if (m_allocationRegister) |
| 131 m_allocationRegister->Remove(address); | 131 m_allocationRegister->Remove(address); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace blink | 134 } // namespace blink |
| OLD | NEW |