Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: Source/platform/heap/BlinkGCMemoryDumpProvider.cpp

Issue 1149673002: Adding blink gc memory dump infrastructure for thread specific dumps. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixing nits. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/WebMemoryAllocatorDump.h" 10 #include "public/platform/WebMemoryAllocatorDump.h"
10 #include "public/platform/WebProcessMemoryDump.h" 11 #include "public/platform/WebProcessMemoryDump.h"
11 #include "wtf/StdLibExtras.h" 12 #include "wtf/StdLibExtras.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 BlinkGCMemoryDumpProvider* BlinkGCMemoryDumpProvider::instance() 16 BlinkGCMemoryDumpProvider* BlinkGCMemoryDumpProvider::instance()
16 { 17 {
17 DEFINE_STATIC_LOCAL(BlinkGCMemoryDumpProvider, instance, ()); 18 DEFINE_STATIC_LOCAL(BlinkGCMemoryDumpProvider, instance, ());
18 return &instance; 19 return &instance;
19 } 20 }
20 21
21 bool BlinkGCMemoryDumpProvider::onMemoryDump(blink::WebProcessMemoryDump* memory Dump)
22 {
23 WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDum p("blink_gc");
24 allocatorDump->AddScalar("inner_size", "bytes", Heap::allocatedObjectSize()) ;
25 allocatorDump->AddScalar("outer_size", "bytes", Heap::allocatedSpace());
26 allocatorDump->AddScalar("estimated_live_object_size", "bytes", Heap::estima tedLiveObjectSize());
27 return true;
28 }
29
30 BlinkGCMemoryDumpProvider::BlinkGCMemoryDumpProvider()
31 {
32 }
33
34 BlinkGCMemoryDumpProvider::~BlinkGCMemoryDumpProvider() 22 BlinkGCMemoryDumpProvider::~BlinkGCMemoryDumpProvider()
35 { 23 {
36 } 24 }
37 25
26 bool BlinkGCMemoryDumpProvider::onMemoryDump(WebProcessMemoryDump* memoryDump)
27 {
28 // The current heap statistics are added to the memory dump.
29 // TODO(ssid): For consistency these values should be dumped at the time of
30 // GC (when statistics are collected). crbug.com/491248.
31 WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDum p("blink_gc");
32 allocatorDump->AddScalar("inner_size", "bytes", Heap::allocatedObjectSize()) ;
33 allocatorDump->AddScalar("outer_size", "bytes", Heap::allocatedSpace());
34 allocatorDump->AddScalar("estimated_live_object_size", "bytes", Heap::estima tedLiveObjectSize());
35
36 // If available, the last GC memory statistics are added.
haraken 2015/05/26 12:21:59 I'm not sure if this is a good design. I think we
Primiano Tucci (use gerrit) 2015/05/26 14:18:03 See my previous comment on this [1]. Regardless of
37 if (m_lastProcessMemoryDump)
38 memoryDump->takeAllDumpsFrom(m_lastProcessMemoryDump.get());
39
40 // TODO(ssid): This should return false in the unlikely case that we didn't
41 // see a GC yet, which in turn will cause the dump to be invalidated. But,
42 // right now returning false will stop the manager from getting more dumps
43 // from this provider. So, always returns true while crbug.com/490783 gets
44 // fixed.
45
46 return true;
47 }
48
49 BlinkGCMemoryDumpProvider::BlinkGCMemoryDumpProvider()
50 : m_lastProcessMemoryDump(adoptPtr(Platform::current()->createProcessMemoryD ump()))
51 {
52 }
53
54 WebMemoryAllocatorDump* BlinkGCMemoryDumpProvider::createMemoryAllocatorDumpForL astGC(const String& absoluteName)
Primiano Tucci (use gerrit) 2015/05/26 11:24:06 I think this should be PassOwnPtr<WebMemoryAllocat
ssid 2015/05/27 13:15:06 No, the caller can't take the ownership of the ptr
Primiano Tucci (use gerrit) 2015/05/27 14:19:30 Oh right, I didn't realize this comes from createM
55 {
56 return m_lastProcessMemoryDump->createMemoryAllocatorDump(absoluteName);
57 }
58
59 void BlinkGCMemoryDumpProvider::clearLastGCProcessMemoryDump()
Primiano Tucci (use gerrit) 2015/05/26 11:24:06 And since you are here, I just realized that a bet
ssid 2015/05/27 13:15:06 removed method.
60 {
61 // TODO(ssid): Once the api for clearing dump is available, use that
62 // instead of this method here (crbug.com/491248).
63 m_lastProcessMemoryDump = adoptPtr(Platform::current()->createProcessMemoryD ump());
64 }
65
38 } // namespace blink 66 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698