c++malloclibctcmallocgperftools

Use gperftools' heap profiler to profile libc malloc


I am trying to profile an application to compare its performance using different allocation strategies.

I have no trouble profiling it when using tcmalloc but how to profile it using libc's allocation functions ? Indeed, enabling gperftool's heap profiler requires to use -ltcmalloc flag¹ but this results as tcmalloc being used as allocation strategy.


Solution

  • how to profile it using libc's allocation functions?

    Note: this requirement is a bit strange: it's not like your application will suddenly start using more or less heap memory, or change its allocation pattern or sites when you switch from tcmalloc to GLIBC malloc.

    From https://gperftools.github.io/gperftools/heapprofile.html:

    Heap profiling requires the use of libtcmalloc. This requirement may be removed in a future version of the heap profiler, and the heap profiler separated out into its own library.

    So you can

    I am not aware of any existing GLIBC equivalents that work today.