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

Side by Side Diff: content/child/child_discardable_shared_memory_manager.cc

Issue 2012763004: [tracing] Only add totals from discardable memory in background mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@whitelist_mdp
Patch Set: Created 4 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 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/child/child_discardable_shared_memory_manager.h" 5 #include "content/child/child_discardable_shared_memory_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/atomic_sequence_num.h" 10 #include "base/atomic_sequence_num.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 MemoryUsageChanged(heap_.GetSize(), heap_.GetSizeOfFreeLists()); 208 MemoryUsageChanged(heap_.GetSize(), heap_.GetSizeOfFreeLists());
209 209
210 return base::WrapUnique(new DiscardableMemoryImpl(this, std::move(new_span))); 210 return base::WrapUnique(new DiscardableMemoryImpl(this, std::move(new_span)));
211 } 211 }
212 212
213 bool ChildDiscardableSharedMemoryManager::OnMemoryDump( 213 bool ChildDiscardableSharedMemoryManager::OnMemoryDump(
214 const base::trace_event::MemoryDumpArgs& args, 214 const base::trace_event::MemoryDumpArgs& args,
215 base::trace_event::ProcessMemoryDump* pmd) { 215 base::trace_event::ProcessMemoryDump* pmd) {
216 base::AutoLock lock(lock_); 216 base::AutoLock lock(lock_);
217 if (args.level_of_detail ==
218 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND) {
219 base::trace_event::MemoryAllocatorDump* total_dump =
220 pmd->CreateAllocatorDump("discardable");
221 const size_t total_size = heap_.GetSize();
222 const size_t freelist_size = heap_.GetSizeOfFreeLists();
223 total_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
224 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
225 total_size - freelist_size);
226 total_dump->AddScalar("freelist_size",
227 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
228 freelist_size);
229 return true;
230 }
231
217 return heap_.OnMemoryDump(pmd); 232 return heap_.OnMemoryDump(pmd);
218 } 233 }
219 234
220 void ChildDiscardableSharedMemoryManager::ReleaseFreeMemory() { 235 void ChildDiscardableSharedMemoryManager::ReleaseFreeMemory() {
221 base::AutoLock lock(lock_); 236 base::AutoLock lock(lock_);
222 237
223 size_t heap_size_prior_to_releasing_memory = heap_.GetSize(); 238 size_t heap_size_prior_to_releasing_memory = heap_.GetSize();
224 239
225 // Release both purged and free memory. 240 // Release both purged and free memory.
226 heap_.ReleasePurgedMemory(); 241 heap_.ReleasePurgedMemory();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 "discardable-memory-allocated"; 335 "discardable-memory-allocated";
321 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey, 336 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey,
322 base::Uint64ToString(new_bytes_total)); 337 base::Uint64ToString(new_bytes_total));
323 338
324 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free"; 339 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free";
325 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey, 340 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey,
326 base::Uint64ToString(new_bytes_free)); 341 base::Uint64ToString(new_bytes_free));
327 } 342 }
328 343
329 } // namespace content 344 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698