| OLD | NEW |
| 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 Loading... |
| 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 ChildDiscardableSharedMemoryManager::Statistics |
| 239 ChildDiscardableSharedMemoryManager::GetStatistics() const { |
| 240 base::AutoLock lock(lock_); |
| 241 Statistics stats; |
| 242 stats.total_size = heap_.GetSize(); |
| 243 stats.freelist_size = heap_.GetSizeOfFreeLists(); |
| 244 return stats; |
| 245 } |
| 246 |
| 238 void ChildDiscardableSharedMemoryManager::ReleaseFreeMemory() { | 247 void ChildDiscardableSharedMemoryManager::ReleaseFreeMemory() { |
| 239 base::AutoLock lock(lock_); | 248 base::AutoLock lock(lock_); |
| 240 | 249 |
| 241 size_t heap_size_prior_to_releasing_memory = heap_.GetSize(); | 250 size_t heap_size_prior_to_releasing_memory = heap_.GetSize(); |
| 242 | 251 |
| 243 // Release both purged and free memory. | 252 // Release both purged and free memory. |
| 244 heap_.ReleasePurgedMemory(); | 253 heap_.ReleasePurgedMemory(); |
| 245 heap_.ReleaseFreeMemory(); | 254 heap_.ReleaseFreeMemory(); |
| 246 | 255 |
| 247 if (heap_.GetSize() != heap_size_prior_to_releasing_memory) | 256 if (heap_.GetSize() != heap_size_prior_to_releasing_memory) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 "discardable-memory-allocated"; | 347 "discardable-memory-allocated"; |
| 339 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey, | 348 base::debug::SetCrashKeyValue(kDiscardableMemoryAllocatedKey, |
| 340 base::Uint64ToString(new_bytes_total)); | 349 base::Uint64ToString(new_bytes_total)); |
| 341 | 350 |
| 342 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free"; | 351 static const char kDiscardableMemoryFreeKey[] = "discardable-memory-free"; |
| 343 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey, | 352 base::debug::SetCrashKeyValue(kDiscardableMemoryFreeKey, |
| 344 base::Uint64ToString(new_bytes_free)); | 353 base::Uint64ToString(new_bytes_free)); |
| 345 } | 354 } |
| 346 | 355 |
| 347 } // namespace content | 356 } // namespace content |
| OLD | NEW |