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

Unified Diff: base/process/memory_linux.cc

Issue 1610153002: Allocator cleanup: move tcmalloc-specific calls to base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_nonbase_tcmalloc_1
Patch Set: rebase Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: base/process/memory_linux.cc
diff --git a/base/process/memory_linux.cc b/base/process/memory_linux.cc
index 6cdc2ca40cde091e7a6110324c4571c9ac136842..b5c964084870a927d8adb60e8692f4b6fa5819d7 100644
--- a/base/process/memory_linux.cc
+++ b/base/process/memory_linux.cc
@@ -16,19 +16,7 @@
#include "build/build_config.h"
#if defined(USE_TCMALLOC)
-// Used by UncheckedMalloc. If tcmalloc is linked to the executable
-// this will be replaced by a strong symbol that actually implement
-// the semantics and don't call new handler in case the allocation fails.
-extern "C" {
-
-__attribute__((weak, visibility("default")))
-void* tc_malloc_skip_new_handler_weak(size_t size);
-
-void* tc_malloc_skip_new_handler_weak(size_t size) {
- return malloc(size);
-}
-
-}
+#include "third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h"
#endif
namespace base {
@@ -162,6 +150,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)
+ // For tcmalloc, we need to tell it to behave like new.
+ tc_set_new_mode(1);
+#endif
}
// NOTE: This is not the only version of this function in the source:
@@ -208,7 +200,7 @@ bool UncheckedMalloc(size_t size, void** result) {
#elif defined(LIBC_GLIBC) && !defined(USE_TCMALLOC)
*result = __libc_malloc(size);
#elif defined(USE_TCMALLOC)
- *result = tc_malloc_skip_new_handler_weak(size);
+ *result = tc_malloc_skip_new_handler(size);
#endif
return *result != NULL;
}
« no previous file with comments | « no previous file | content/app/content_main_runner.cc » ('j') | third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698