Cannot use TCMalloc

Basile B. via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 31 14:26:45 PDT 2016


On Thursday, 31 March 2016 at 20:21:00 UTC, Nordlöw wrote:
> On Thursday, 31 March 2016 at 19:09:20 UTC, Basile B. wrote:
>> You need to install the "-devel" version to get the it as a 
>> static library. On OpenSuse it's named gperftools-devel.
>>
>> Maybe on ubuntu it's this one:
>>
>> "libgoogle-perftools-dev"
>>
>> http://packages.ubuntu.com/fr/trusty/amd64/libgoogle-perftools-dev/filelist, because it contains the "*.a" static library you wanna link in.
>
> Works. Wonderful. Thanks.
>
> BTW: Will this affect D's builtin GC or does it use mmap 
> directly?

It looks like if you manage to hook default malloc, free etc the 
GC will be affected.

But a simple try to call the functions from the static lib fails 
(the first script line is passed to DMD by my editor):


     #!runnable flags: -L-ltcmalloc
     extern(C) void* tc_malloc(size_t size);
     extern(C) void  tc_free(void* ptr);

     void main(string[] args)
     {
         auto p = tc_malloc(16);
         tc_free(p);
     }

/tmp/temp_7FCC33C16DF0.d:(.text._Dmain+0xa): référence 
indéfinie vers « tc_malloc »
/tmp/temp_7FCC33C16DF0.d:(.text._Dmain+0x12): référence 
indéfinie vers « tc_free »

interface seems to be this:
https://github.com/gperftools/gperftools/blob/master/src/gperftools/tcmalloc.h.in#L88

Do you have the interface or the D sources to call the functions ?


More information about the Digitalmars-d mailing list