From 2f12866bc20d9231f33ac77512039603d6638a79 Mon Sep 17 00:00:00 2001 From: Maxim Akhmedov Date: Fri, 24 Jan 2020 01:12:01 +0300 Subject: [PATCH] Introduce macro for disabling allocator mmapping. --- dbms/src/Common/Allocator.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dbms/src/Common/Allocator.h b/dbms/src/Common/Allocator.h index 5d39d327243..12116f6d8d3 100644 --- a/dbms/src/Common/Allocator.h +++ b/dbms/src/Common/Allocator.h @@ -50,16 +50,21 @@ * * P.S. This is also required, because tcmalloc can not allocate a chunk of * memory greater than 16 GB. + * + * P.P.S. Note that MMAP_THRESHOLD symbol is intentionally made weak. It allows + * to override it during linkage when using ClickHouse as a library in + * third-party applications which may already use own allocator doing mmaps + * in the implementation of alloc/realloc. */ #ifdef NDEBUG - static constexpr size_t MMAP_THRESHOLD = 64 * (1ULL << 20); + __attribute__((__weak__)) extern const size_t MMAP_THRESHOLD = 64 * (1ULL << 20); #else /** * In debug build, use small mmap threshold to reproduce more memory * stomping bugs. Along with ASLR it will hopefully detect more issues than * ASan. The program may fail due to the limit on number of memory mappings. */ - static constexpr size_t MMAP_THRESHOLD = 4096; + __attribute__((__weak__)) extern const size_t MMAP_THRESHOLD = 4096; #endif static constexpr size_t MMAP_MIN_ALIGNMENT = 4096;