Reputation: 347
I installed tcmalloc on Ubuntu 14.0 using apt-get install libtcmalloc-minimal4
I did following steps:
ln -s libtcmalloc_minimal.so.4.1.2 libtcmalloc_minimal.so
linked my executable with -ltcmalloc_minimal
After running the code, I can not see any performance difference.
I tried to run with HEAPCHECK to check if tcmalloc is being used, but did not found any warnings associated with HEAPCHECK.
My programs contains malloc calls and openMP. Is there any thing else I need to do? How can I check to make sure that tcmalloc is being used by my program?
Upvotes: 1
Views: 4575
Reputation: 1301
You could put a breakpoint at malloc(), e.g. in GDB:
(gdb) break malloc
Breakpoint 2 at 0x7ffff72b2130 (3 locations)
If TC-Malloc is being used, you'll see the following when a dynamic allocaiton is made:
Breakpoint 2, 0x00007ffff7ba8c20 in tc_malloc () from /lib64/libtcmalloc_minimal.so.4
(gdb) bt
#0 0x00007ffff7ba8c20 in tc_malloc () from /lib64/libtcmalloc_minimal.so.4
#1 0x00007ffff729e45d in __fopen_internal () from /lib64/libc.so.6
Upvotes: 1
Reputation: 213646
I did following steps:
ln -s libtcmalloc_minimal.so.4.1.2 libtcmalloc_minimal.so
linked my executable with-ltcmalloc_minimal
In general, it should never be necessary to symlink a library like that. The fact that you had to do that tells me that you did not install correct (development) package.
ldd
gives "not a dynamic executable".
In that case, your executable is guaranteed to not have been linked with libtcmalloc_minimal.so
.
I have linked the library using
-L <path to .so>
That does not link your executable to any specific library, it merely tell your linker to look in <path to .so>
directory for libraries. You need to actually ask the linker to look for libtcmalloc_minimal
, with -ltcmalloc_minimal
flag.
Upvotes: 2
Reputation: 347
Got following response from google-perftool group to check if tcmalloc is being used by my program:
Setting environment variable MALLOCSTATS to 1 or 2 should print some tcmalloc statistics at the end.
E.g. MALLOCSTATS=2 ./myprogram
Upvotes: 1