c++cmemory-managementdlopenjemalloc

How to dlopen jemalloc dynamic library


I am trying to dlopen memory allocators at runtime. I have no problem with libc, tcmalloc and tbbmalloc. But trying to dlopen jemalloc results in the following error (caught via dlerror) :

/path/to/lib/libjemalloc.so: cannot allocate memory in static TLS block

Do you have any idea of the reason for this error and hence how I could tackle this ?


Solution

  • I was able to find a solution to this thanks to jemalloc's GitHub repository issue #1237.

    This solution was to recompile jemalloc using the --disable-initial-exec-tls according to the INSTALL.md, my bad.