The common usage of tcmalloc vs glibc is "glibc malloc/free is the default; use LD_PRELOAD to use tcmalloc".
An application I'm working on, they want the reverse: tcmalloc by default, but glibc's malloc/free as an option. (Environment is RHEL7, gcc 11.2.0)
The obvious method is linking with -ltcmalloc_minimal, and use LD_PRELOAD=libc.so.6 to force libc. It seems to be working, but this just feels ... too simple. Changing the C-runtime bootstrap is usually a painful, complex process. Am I missing something? Or am I just being paranoid?
Related question: Is there a way to determine from within main(), which malloc is in use?