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

Unified Diff: Source/platform/heap/BlinkGCMemoryDumpProvider.cpp

Issue 1281673003: [tracing] Adding support for light dumps in blink gc dump provider (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixing test. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/platform/heap/BlinkGCMemoryDumpProviderTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/BlinkGCMemoryDumpProvider.cpp
diff --git a/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp b/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp
index 62c4c54e54c9154517dd2400d74e5fae8d9cb387..f0ba7bf002ec4964ab7f8e73a342264d7d106058 100644
--- a/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp
+++ b/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp
@@ -13,6 +13,23 @@
#include "wtf/Threading.h"
namespace blink {
+namespace {
+
+void dumpMemoryTotals(blink::WebProcessMemoryDump* memoryDump)
+{
+ String dumpName = String::format("blink_gc");
+ WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDump(dumpName);
+ allocatorDump->AddScalar("size", "bytes", Heap::allocatedSpace());
+
+ dumpName.append("/allocated_objects");
+ WebMemoryAllocatorDump* objectsDump = memoryDump->createMemoryAllocatorDump(dumpName);
+
+ // Heap::markedObjectSize() can be underestimated if we're still in the
+ // process of lazy sweeping.
+ objectsDump->AddScalar("size", "bytes", Heap::allocatedObjectSize() + Heap::markedObjectSize());
+}
+
+} // namespace
BlinkGCMemoryDumpProvider* BlinkGCMemoryDumpProvider::instance()
{
@@ -26,16 +43,13 @@ BlinkGCMemoryDumpProvider::~BlinkGCMemoryDumpProvider()
bool BlinkGCMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, blink::WebProcessMemoryDump* memoryDump)
{
- // TODO(ssid): Use levelOfDetail to create light dumps when requested (crbug.com/499731).
+ if (levelOfDetail == WebMemoryDumpLevelOfDetail::Low) {
+ dumpMemoryTotals(memoryDump);
+ return true;
+ }
Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::TakeSnapshot, Heap::ForcedGC);
- String dumpName = String::format("blink_gc/thread_%lu", static_cast<unsigned long>(WTF::currentThread()));
- WebMemoryAllocatorDump* allocatorDump = memoryDump->createMemoryAllocatorDump(dumpName);
- allocatorDump->AddScalar("size", "bytes", Heap::allocatedSpace());
-
- dumpName.append("/allocated_objects");
- WebMemoryAllocatorDump* objectsDump = memoryDump->createMemoryAllocatorDump(dumpName);
- objectsDump->AddScalar("size", "bytes", Heap::allocatedObjectSize() + Heap::markedObjectSize());
+ dumpMemoryTotals(memoryDump);
// Merge all dumps collected by Heap::collectGarbage.
memoryDump->takeAllDumpsFrom(m_currentProcessMemoryDump.get());
« no previous file with comments | « no previous file | Source/platform/heap/BlinkGCMemoryDumpProviderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698