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

Side by Side Diff: content/common/discardable_shared_memory_heap.cc

Issue 1375963007: [tracing] Display the resident size of the discardable memory segments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lock_discardable
Patch Set: Fix mac. Created 5 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/common/discardable_shared_memory_heap.h" 5 #include "content/common/discardable_shared_memory_heap.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/discardable_shared_memory.h" 10 #include "base/memory/discardable_shared_memory.h"
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 size_t locked_objects_size_in_bytes = locked_objects_blocks * block_size_; 388 size_t locked_objects_size_in_bytes = locked_objects_blocks * block_size_;
389 389
390 std::string segment_dump_name = 390 std::string segment_dump_name =
391 base::StringPrintf("discardable/segment_%d", segment_id); 391 base::StringPrintf("discardable/segment_%d", segment_id);
392 base::trace_event::MemoryAllocatorDump* segment_dump = 392 base::trace_event::MemoryAllocatorDump* segment_dump =
393 pmd->CreateAllocatorDump(segment_dump_name); 393 pmd->CreateAllocatorDump(segment_dump_name);
394 segment_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 394 segment_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
395 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 395 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
396 size); 396 size);
397 397
398 ssize_t resident_size =
399 base::trace_event::ProcessMemoryDump::CountResidentBytes(
400 shared_memory->memory(), shared_memory->mapped_size());
401 if (resident_size >= 0) {
402 segment_dump->AddScalar("resident_size",
403 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
404 static_cast<uint64>(resident_size));
405 }
406
398 base::trace_event::MemoryAllocatorDump* obj_dump = 407 base::trace_event::MemoryAllocatorDump* obj_dump =
399 pmd->CreateAllocatorDump(segment_dump_name + "/allocated_objects"); 408 pmd->CreateAllocatorDump(segment_dump_name + "/allocated_objects");
400 obj_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, 409 obj_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount,
401 base::trace_event::MemoryAllocatorDump::kUnitsObjects, 410 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
402 allocated_objects_count); 411 allocated_objects_count);
403 obj_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 412 obj_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
404 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 413 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
405 allocated_objects_size_in_bytes); 414 allocated_objects_size_in_bytes);
406 obj_dump->AddScalar("locked_size", 415 obj_dump->AddScalar("locked_size",
407 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 416 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 ScopedVector<ScopedMemorySegment>::const_iterator it = 457 ScopedVector<ScopedMemorySegment>::const_iterator it =
449 std::find_if(memory_segments_.begin(), memory_segments_.end(), 458 std::find_if(memory_segments_.begin(), memory_segments_.end(),
450 [span](const ScopedMemorySegment* segment) { 459 [span](const ScopedMemorySegment* segment) {
451 return segment->ContainsSpan(span); 460 return segment->ContainsSpan(span);
452 }); 461 });
453 DCHECK(it != memory_segments_.end()); 462 DCHECK(it != memory_segments_.end());
454 return (*it)->CreateMemoryAllocatorDump(span, block_size_, name, pmd); 463 return (*it)->CreateMemoryAllocatorDump(span, block_size_, name, pmd);
455 } 464 }
456 465
457 } // namespace content 466 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698