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

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

Issue 2350423003: [Tentaive patch for discussion] Add Purge+Suspend metrics as UMA.
Patch Set: Add v8 heap usage Created 4 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/child/child_discardable_shared_memory_manager.h" 5 #include "content/child/child_discardable_shared_memory_manager.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 total_size - freelist_size); 228 total_size - freelist_size);
229 total_dump->AddScalar("freelist_size", 229 total_dump->AddScalar("freelist_size",
230 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 230 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
231 freelist_size); 231 freelist_size);
232 return true; 232 return true;
233 } 233 }
234 234
235 return heap_.OnMemoryDump(pmd); 235 return heap_.OnMemoryDump(pmd);
236 } 236 }
237 237
238 size_t ChildDiscardableSharedMemoryManager::GetMemoryUsage() const {
bashi 2016/09/22 23:28:26 It may be consistent when this returns a struct li
239 base::AutoLock lock(lock_);
240 const size_t total_size = heap_.GetSize();
241 const size_t freelist_size = heap_.GetSizeOfFreeLists();
242 return total_size - freelist_size;
243 }
244
238 void ChildDiscardableSharedMemoryManager::ReleaseFreeMemory() { 245 void ChildDiscardableSharedMemoryManager::ReleaseFreeMemory() {
239 base::AutoLock lock(lock_); 246 base::AutoLock lock(lock_);
240 247
241 size_t heap_size_prior_to_releasing_memory = heap_.GetSize(); 248 size_t heap_size_prior_to_releasing_memory = heap_.GetSize();
242 249
243 // Release both purged and free memory. 250 // Release both purged and free memory.
244 heap_.ReleasePurgedMemory(); 251 heap_.ReleasePurgedMemory();
245 heap_.ReleaseFreeMemory(); 252 heap_.ReleaseFreeMemory();
246 253
247 if (heap_.GetSize() != heap_size_prior_to_releasing_memory) 254 if (heap_.GetSize() != heap_size_prior_to_releasing_memory)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 "discardable-memory-allocated"; 345 "discardable-memory-allocated";
339 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey, 346 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey,
340 base::Uint64ToString(new_bytes_total)); 347 base::Uint64ToString(new_bytes_total));
341 348
342 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free"; 349 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free";
343 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey, 350 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey,
344 base::Uint64ToString(new_bytes_free)); 351 base::Uint64ToString(new_bytes_free));
345 } 352 }
346 353
347 } // namespace content 354 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698