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

Unified Diff: content/common/discardable_shared_memory_heap.cc

Issue 1100073004: Adding discardable memory dump provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments. Created 5 years, 8 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
Index: content/common/discardable_shared_memory_heap.cc
diff --git a/content/common/discardable_shared_memory_heap.cc b/content/common/discardable_shared_memory_heap.cc
index 36ee632255329506570831c90bc23287cad00580..0ce039f872b72270e05dc0ffbfc7711899786956 100644
--- a/content/common/discardable_shared_memory_heap.cc
+++ b/content/common/discardable_shared_memory_heap.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include "base/memory/discardable_shared_memory.h"
+#include "base/strings/stringprintf.h"
namespace content {
namespace {
@@ -212,6 +213,37 @@ size_t DiscardableSharedMemoryHeap::GetSizeOfFreeLists() const {
return num_free_blocks_ * block_size_;
}
+bool DiscardableSharedMemoryHeap::DumpMemoryStatisticsInto(
+ base::trace_event::ProcessMemoryDump* pmd) {
+ for (size_t segment = 0; segment < memory_segments_.size(); segment++) {
reveman 2015/04/24 14:19:36 Would be nice to do something c++-ish like Release
ssid 2015/04/27 11:19:20 Thanks done.
+ std::string segment_id = base::StringPrintf("segment_%zu", segment);
reveman 2015/04/24 14:19:36 nit: maybe move "segment" string to a kMemoryAlloc
ssid 2015/04/27 11:19:20 Done.
+ base::trace_event::MemoryAllocatorDump* segment_dump =
+ pmd->CreateAllocatorDump("discardable", segment_id.c_str());
reveman 2015/04/24 14:19:36 nit: and maybe move this string to a kMemoryAlloca
ssid 2015/04/27 11:19:20 Done.
+
+ size_t num_of_objects = 0;
reveman 2015/04/24 14:19:36 nit: allocated_objects_count Might as well keep t
ssid 2015/04/27 11:19:20 Done.
+ size_t used_size = 0;
reveman 2015/04/24 14:19:36 nit: allocated_objects_size_in_bytes
ssid 2015/04/27 11:19:20 Done.
+ size_t offset = reinterpret_cast<size_t>(
+ memory_segments_[segment]->shared_memory_->memory()) /
+ block_size_;
+ size_t end = offset + memory_segments_[segment]->size_ / block_size_;
+ while (offset < end) {
+ Span* span = spans_[offset];
+ if (!IsInFreeList(span)) {
+ num_of_objects++;
+ used_size += span->length_;
+ }
+ offset += span->length_;
+ }
+
+ segment_dump->set_physical_size_in_bytes(
+ static_cast<int>(memory_segments_[segment]->size_));
+ segment_dump->set_allocated_objects_count(static_cast<int>(num_of_objects));
+ segment_dump->set_allocated_objects_size_in_bytes(
+ static_cast<int>(used_size));
+ }
+ return true;
+}
+
void DiscardableSharedMemoryHeap::InsertIntoFreeList(
scoped_ptr<DiscardableSharedMemoryHeap::Span> span) {
DCHECK(!IsInFreeList(span.get()));

Powered by Google App Engine
This is Rietveld 408576698