OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/process/memory.h" | 5 #include "base/process/memory.h" |
6 | 6 |
7 #include "base/allocator/allocator_interception_mac.h" | 7 #include "base/allocator/allocator_interception_mac.h" |
8 #include "base/allocator/allocator_shim.h" | 8 #include "base/allocator/allocator_shim.h" |
9 #include "base/allocator/features.h" | 9 #include "base/allocator/features.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 bool UncheckedCalloc(size_t num_items, size_t size, void** result) { | 30 bool UncheckedCalloc(size_t num_items, size_t size, void** result) { |
31 return allocator::UncheckedCallocMac(num_items, size, result); | 31 return allocator::UncheckedCallocMac(num_items, size, result); |
32 } | 32 } |
33 | 33 |
34 void EnableTerminationOnOutOfMemory() { | 34 void EnableTerminationOnOutOfMemory() { |
35 // Step 1: Enable OOM killer on C++ failures. | 35 // Step 1: Enable OOM killer on C++ failures. |
36 std::set_new_handler(oom_killer_new); | 36 std::set_new_handler(oom_killer_new); |
37 | 37 |
38 // Step 2: Enable OOM killer on C-malloc failures for the default zone (if we | 38 // Step 2: Enable OOM killer on C-malloc failures for the default zone (if we |
39 // have a shim). | 39 // have a shim). |
40 #if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) | 40 #if BUILDFLAG(USE_ALLOCATOR_SHIM) |
41 allocator::SetCallNewHandlerOnMallocFailure(true); | 41 allocator::SetCallNewHandlerOnMallocFailure(true); |
42 #endif | 42 #endif |
43 | 43 |
44 // Step 3: Enable OOM killer on all other malloc zones (or just "all" without | 44 // Step 3: Enable OOM killer on all other malloc zones (or just "all" without |
45 // "other" if shim is disabled). | 45 // "other" if shim is disabled). |
46 allocator::InterceptAllocationsMac(); | 46 allocator::InterceptAllocationsMac(); |
47 } | 47 } |
48 | 48 |
49 } // namespace base | 49 } // namespace base |
OLD | NEW |