Index: base/process/memory_linux.cc |
diff --git a/base/process/memory_linux.cc b/base/process/memory_linux.cc |
index b5c964084870a927d8adb60e8692f4b6fa5819d7..9fb630b4750bff97a952850c655b8159fe9c075d 100644 |
--- a/base/process/memory_linux.cc |
+++ b/base/process/memory_linux.cc |
@@ -8,6 +8,8 @@ |
#include <new> |
+#include "base/allocator/allocator_shim.h" |
+#include "base/allocator/features.h" |
#include "base/files/file_path.h" |
#include "base/files/file_util.h" |
#include "base/logging.h" |
@@ -41,8 +43,12 @@ void OnNoMemory() { |
} // namespace |
+// TODO(primiano): Once the unified shim is on by default (crbug.com/550886) |
+// get rid of the code in this entire #if section. The whole termination-on-OOM |
+// logic is implemented in the shim. |
#if !defined(ADDRESS_SANITIZER) && !defined(MEMORY_SANITIZER) && \ |
- !defined(THREAD_SANITIZER) && !defined(LEAK_SANITIZER) |
+ !defined(THREAD_SANITIZER) && !defined(LEAK_SANITIZER) && \ |
+ !BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) |
#if defined(LIBC_GLIBC) && !defined(USE_TCMALLOC) |
@@ -150,7 +156,10 @@ void EnableTerminationOnOutOfMemory() { |
// If we're using glibc's allocator, the above functions will override |
// malloc and friends and make them die on out of memory. |
#endif |
-#if defined(USE_TCMALLOC) |
+ |
+#if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) |
+ allocator::SetCallNewHandlerOnMallocFailure(true); |
+#elif defined(USE_TCMALLOC) |
// For tcmalloc, we need to tell it to behave like new. |
tc_set_new_mode(1); |
#endif |
@@ -194,7 +203,9 @@ bool AdjustOOMScore(ProcessId process, int score) { |
} |
bool UncheckedMalloc(size_t size, void** result) { |
-#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) || \ |
+#if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) |
+ *result = allocator::UncheckedAlloc(size); |
+#elif defined(MEMORY_TOOL_REPLACES_ALLOCATOR) || \ |
(!defined(LIBC_GLIBC) && !defined(USE_TCMALLOC)) |
*result = malloc(size); |
#elif defined(LIBC_GLIBC) && !defined(USE_TCMALLOC) |