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 "config.h" | 5 #include "config.h" |
6 #include "Source/platform/heap/BlinkGCMemoryDumpProvider.h" | 6 #include "Source/platform/heap/BlinkGCMemoryDumpProvider.h" |
7 | 7 |
8 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
9 #include "public/platform/Platform.h" | 9 #include "public/platform/Platform.h" |
10 #include "public/platform/WebMemoryAllocatorDump.h" | 10 #include "public/platform/WebMemoryAllocatorDump.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 } | 21 } |
22 | 22 |
23 BlinkGCMemoryDumpProvider::~BlinkGCMemoryDumpProvider() | 23 BlinkGCMemoryDumpProvider::~BlinkGCMemoryDumpProvider() |
24 { | 24 { |
25 } | 25 } |
26 | 26 |
27 bool BlinkGCMemoryDumpProvider::onMemoryDump(blink::WebProcessMemoryDump* memory
Dump) | 27 bool BlinkGCMemoryDumpProvider::onMemoryDump(blink::WebProcessMemoryDump* memory
Dump) |
28 { | 28 { |
29 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::TakeSn
apshot, Heap::ForcedGC); | 29 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::TakeSn
apshot, Heap::ForcedGC); |
30 String dumpName = String::format("blink_gc/thread_%lu", static_cast<unsigned
long>(WTF::currentThread())); | 30 String dumpName = String::format("blink_gc/thread_%lu", static_cast<unsigned
long>(WTF::currentThread())); |
31 WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDum
p(dumpName); | 31 WebMemoryAllocatorDump* allocatorDump = m_currentProcessMemoryDump->getMemor
yAllocatorDump(dumpName); |
| 32 if (!allocatorDump) |
| 33 allocatorDump = m_currentProcessMemoryDump->createMemoryAllocatorDump(du
mpName); |
32 allocatorDump->AddScalar("size", "bytes", Heap::allocatedSpace()); | 34 allocatorDump->AddScalar("size", "bytes", Heap::allocatedSpace()); |
33 | 35 |
34 dumpName.append("/allocated_objects"); | 36 dumpName.append("/allocated_objects"); |
35 WebMemoryAllocatorDump* objectsDump = memoryDump->createMemoryAllocatorDump(
dumpName); | 37 WebMemoryAllocatorDump* objectsDump = m_currentProcessMemoryDump->createMemo
ryAllocatorDump(dumpName); |
36 objectsDump->AddScalar("size", "bytes", Heap::allocatedObjectSize() + Heap::
markedObjectSize()); | 38 objectsDump->AddScalar("size", "bytes", Heap::allocatedObjectSize() + Heap::
markedObjectSize()); |
37 objectsDump->AddScalar("estimated_live_object_size", "bytes", Heap::estimate
dLiveObjectSize()); | 39 objectsDump->AddScalar("estimated_live_object_size", "bytes", Heap::estimate
dLiveObjectSize()); |
38 | 40 |
39 // Merge all dumps collected by Heap::collectGarbage. | 41 // Merge all dumps collected by Heap::collectGarbage. |
40 memoryDump->takeAllDumpsFrom(m_currentProcessMemoryDump.get()); | 42 memoryDump->takeAllDumpsFrom(m_currentProcessMemoryDump.get()); |
41 return true; | 43 return true; |
42 } | 44 } |
43 | 45 |
44 WebMemoryAllocatorDump* BlinkGCMemoryDumpProvider::createMemoryAllocatorDumpForC
urrentGC(const String& absoluteName) | 46 WebMemoryAllocatorDump* BlinkGCMemoryDumpProvider::createMemoryAllocatorDumpForC
urrentGC(const String& absoluteName) |
45 { | 47 { |
46 return m_currentProcessMemoryDump->createMemoryAllocatorDump(absoluteName); | 48 return m_currentProcessMemoryDump->createMemoryAllocatorDump(absoluteName); |
47 } | 49 } |
48 | 50 |
49 void BlinkGCMemoryDumpProvider::clearProcessDumpForCurrentGC() | 51 void BlinkGCMemoryDumpProvider::clearProcessDumpForCurrentGC() |
50 { | 52 { |
51 m_currentProcessMemoryDump->clear(); | 53 m_currentProcessMemoryDump->clear(); |
52 } | 54 } |
53 | 55 |
54 BlinkGCMemoryDumpProvider::BlinkGCMemoryDumpProvider() | 56 BlinkGCMemoryDumpProvider::BlinkGCMemoryDumpProvider() |
55 : m_currentProcessMemoryDump(adoptPtr(Platform::current()->createProcessMemo
ryDump())) | 57 : m_currentProcessMemoryDump(adoptPtr(Platform::current()->createProcessMemo
ryDump())) |
56 { | 58 { |
57 } | 59 } |
58 | 60 |
59 } // namespace blink | 61 } // namespace blink |
OLD | NEW |