1 // Copyright (c) 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "base/allocator/partition_allocator/partition_root_base.h" 6 7 #include "base/allocator/partition_allocator/oom.h" 8 #include "base/allocator/partition_allocator/partition_oom.h" 9 #include "base/allocator/partition_allocator/partition_page.h" 10 #include "build/build_config.h" 11 12 namespace base { 13 namespace internal { 14 OutOfMemory(size_t size)15NOINLINE void PartitionRootBase::OutOfMemory(size_t size) { 16 #if !defined(ARCH_CPU_64_BITS) 17 // Check whether this OOM is due to a lot of super pages that are allocated 18 // but not committed, probably due to http://crbug.com/421387. 19 if (total_size_of_super_pages + total_size_of_direct_mapped_pages - 20 total_size_of_committed_pages > 21 kReasonableSizeOfUnusedPages) { 22 PartitionOutOfMemoryWithLotsOfUncommitedPages(size); 23 } 24 #endif 25 if (PartitionRootBase::g_oom_handling_function) 26 (*PartitionRootBase::g_oom_handling_function)(size); 27 OOM_CRASH(size); 28 } 29 DecommitEmptyPages()30void PartitionRootBase::DecommitEmptyPages() { 31 for (size_t i = 0; i < kMaxFreeableSpans; ++i) { 32 internal::PartitionPage* page = global_empty_page_ring[i]; 33 if (page) 34 page->DecommitIfPossible(this); 35 global_empty_page_ring[i] = nullptr; 36 } 37 } 38 39 } // namespace internal 40 } // namespace base 41