In the src/Makefile:
ifeq ($(uname_S),Linux) ifneq ($(FORCE_LIBC_MALLOC),yes) USE_JEMALLOC=yes endif endif
ifeq ($(uname_S),SunOS) CFLAGS?=-std=c99 -pedantic $(OPTIMIZATION) -Wall -W -D__EXTENSIONS__ -D_XPG6 CCLINK?=-ldl -lnsl -lsocket -lm -lpthread DEBUG?=-g -ggdb else CFLAGS?=-std=c99 -pedantic $(OPTIMIZATION) -Wall -W $(ARCH) $(PROF) CCLINK?=-lm -pthread DEBUG?=-g -rdynamic -ggdb endif
ifeq ($(USE_TCMALLOC),yes) ALLOC_DEP= ALLOC_LINK=-ltcmalloc ALLOC_FLAGS=-DUSE_TCMALLOC endif
ifeq ($(USE_TCMALLOC_MINIMAL),yes) ALLOC_DEP= ALLOC_LINK=-ltcmalloc_minimal ALLOC_FLAGS=-DUSE_TCMALLOC endif
ifeq ($(USE_JEMALLOC),yes) ALLOC_DEP=../deps/jemalloc/lib/libjemalloc.a ALLOC_LINK=$(ALLOC_DEP) -ldl ALLOC_FLAGS=-DUSE_JEMALLOC -I../deps/jemalloc/include endif
It means that the USE_TCMALLOC=yes will never worked on linux, only if the FORCE_LIBC_MALLOC=yes is seted too.
But in the zmalloc.c
if defined(USE_TCMALLOC)
define malloc(size) tc_malloc(size)
define calloc(count,size) tc_calloc(count,size)
define realloc(ptr,size) tc_realloc(ptr,size)
define free(ptr) tc_free(ptr)
elif defined(USE_JEMALLOC)
define malloc(size) je_malloc(size)
define calloc(count,size) je_calloc(count,size)
define realloc(ptr,size) je_realloc(ptr,size)
define free(ptr) je_free(ptr)
endif
The tcmalloc has higher priority than jemalloc.
It makes me confused about the priority policy for those two alloctors. Dose the codes order of Makefile wrong?
Comment From: itamarhaber
Hello @iammutex - this issue has been stale for a while so I'm closing it, please feel free to reopen if needed.