I use tcmalloc in my main program A by adding -ltcmalloc in linking time. When A starts, it will dynamically load several precompiled .so files, such as B.so, C.so.
then, will the malloc() in B.so and C.so use tcmalloc automatically?
I use tcmalloc in my main program A by adding -ltcmalloc in linking time.
Share
Depends on your OS, and possibly on whether you are using archive or shared version of
libtcmalloc.On Linux (and other
ELFplatforms), usinglibtcmalloc.so, the answer is yes.On Linux, using
libtcmalloc.a, the answer is “most likely”. To make it a “definite yes”, add-rdynamicto the link line for the main executable.On AIX, the answer is no, unless you add a bunch of non-trivial options to
B.soandC.solink lines.