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

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

Issue 1583483002: [tracing] Add method to create "weak" global dumps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes. Created 4 years, 11 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
« no previous file with comments | « base/trace_event/process_memory_dump_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <utility> 8 #include <utility>
9 9
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 411 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
412 allocated_objects_size_in_bytes); 412 allocated_objects_size_in_bytes);
413 obj_dump->AddScalar("locked_size", 413 obj_dump->AddScalar("locked_size",
414 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 414 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
415 locked_objects_size_in_bytes); 415 locked_objects_size_in_bytes);
416 416
417 // Emit an ownership edge towards a global allocator dump node. This allows 417 // Emit an ownership edge towards a global allocator dump node. This allows
418 // to avoid double-counting segments when both browser and child process emit 418 // to avoid double-counting segments when both browser and child process emit
419 // them. In the special case of single-process-mode, this will be the only 419 // them. In the special case of single-process-mode, this will be the only
420 // dumper active and the single ownership edge will become a no-op in the UI. 420 // dumper active and the single ownership edge will become a no-op in the UI.
421 // The global dump is created as a weak dump so that the segment is removed if
422 // the browser does not dump it (segment was purged).
421 const uint64_t tracing_process_id = 423 const uint64_t tracing_process_id =
422 base::trace_event::MemoryDumpManager::GetInstance() 424 base::trace_event::MemoryDumpManager::GetInstance()
423 ->GetTracingProcessId(); 425 ->GetTracingProcessId();
424 base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid = 426 base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid =
425 GetSegmentGUIDForTracing(tracing_process_id, segment_id); 427 GetSegmentGUIDForTracing(tracing_process_id, segment_id);
426 pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid); 428 pmd->CreateWeakSharedGlobalAllocatorDump(shared_segment_guid);
427 429
428 // The size is added to the global dump so that it gets propagated to both the 430 // The size is added to the global dump so that it gets propagated to both the
429 // dumps associated. 431 // dumps associated.
430 pmd->GetSharedGlobalAllocatorDump(shared_segment_guid) 432 pmd->GetSharedGlobalAllocatorDump(shared_segment_guid)
431 ->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 433 ->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
432 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 434 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
433 allocated_objects_size_in_bytes); 435 allocated_objects_size_in_bytes);
434 436
435 // By creating an edge with a higher |importance| (w.r.t. browser-side dumps) 437 // By creating an edge with a higher |importance| (w.r.t. browser-side dumps)
436 // the tracing UI will account the effective size of the segment to the child. 438 // the tracing UI will account the effective size of the segment to the child.
(...skipping 26 matching lines...) Expand all
463 ScopedVector<ScopedMemorySegment>::const_iterator it = 465 ScopedVector<ScopedMemorySegment>::const_iterator it =
464 std::find_if(memory_segments_.begin(), memory_segments_.end(), 466 std::find_if(memory_segments_.begin(), memory_segments_.end(),
465 [span](const ScopedMemorySegment* segment) { 467 [span](const ScopedMemorySegment* segment) {
466 return segment->ContainsSpan(span); 468 return segment->ContainsSpan(span);
467 }); 469 });
468 DCHECK(it != memory_segments_.end()); 470 DCHECK(it != memory_segments_.end());
469 return (*it)->CreateMemoryAllocatorDump(span, block_size_, name, pmd); 471 return (*it)->CreateMemoryAllocatorDump(span, block_size_, name, pmd);
470 } 472 }
471 473
472 } // namespace content 474 } // namespace content
OLDNEW
« no previous file with comments | « base/trace_event/process_memory_dump_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698