valgrind

Dmitry Olshansky dmitry.olsh at gmail.com
Sun Mar 10 12:32:07 PDT 2013


10-Mar-2013 17:04, Druzhinin Alexandr пишет:
> On 10.03.2013 19:45, Dmitry Olshansky wrote:
>> 10-Mar-2013 15:06, simendsjo пишет:
>>> I haven't used valgrind/cachegrind on C/C++ programs before, but I'm
>>> pretty sure it doesn't behave as expected on D code. I found this page
>>> to fix the mangling issue: http://wiki.dlang.org/Other_Dev_Tools, but
>>> all callgraphs is empty.
>>
>> I've used it just yesterday with great success. At least callgrind and
>> massif definitely work.
>>
> Dmitry, using massif I get tree like this (there are normal informative
> branches too, of course):
> |
> ->26.85% (10,364,525B) 0xD418247: ???
> | ->09.86% (3,807,325B) 0x1442E08E: ???
> | | ->02.99% (1,155,831B) 0x145188A6: ???
> | | | ->02.99% (1,155,831B) 0x3E: ???
> | | |   ->02.99% (1,155,831B) 0xEB70BC7: ???
> | | |     ->02.99% (1,155,831B) 0x145187CE: ???
> | | |       ->02.99% (1,155,831B) 0x145188A6: ???
>
> how to know who the hell is used my memory? who is Mr. '???'?
> can building phobos and druntime help with it?

Here is what I see when I run it on optimized binary compiled with ldc:
http://sdrv.ms/ZrFgh9

Same compiled with gdc:
http://sdrv.ms/12FPPF3

And dmd also optimized:
http://sdrv.ms/15Gj7RF

And it looks good.

I didn't bother to check the text dump in depth but here is one slice:

n6: 41816 (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
  n1: 8208 0x540209: _D2gc3gcx4Pool10initializeMFmbZv (in 
/home/dmitry/Dscanner/dscanner-dmd)
   n1: 8208 0x53EBEB: _D2gc3gcx3Gcx7newPoolMFmbZPS2gc3gcx4Pool (in 
/home/dmitry/Dscanner/dscanner-dmd)
    n1: 8208 0x53C33B: _D2gc3gcx2GC12mallocNoSyncMFmkPmZPv (in 
/home/dmitry/Dscanner/dscanner-dmd)
     n1: 8208 0x53C1F1: _D2gc3gcx2GC6mallocMFmkPmZPv (in 
/home/dmitry/Dscanner/dscanner-dmd)
      n1: 8208 0x51CABB: gc_malloc (in /home/dmitry/Dscanner/dscanner-dmd)
       n1: 8208 0x51E7A6: _d_newclass (in 
/home/dmitry/Dscanner/dscanner-dmd)
        n1: 8208 0x545123: thread_attachThis (in 
/home/dmitry/Dscanner/dscanner-dmd)
         n1: 8208 0x5450B5: thread_init (in 
/home/dmitry/Dscanner/dscanner-dmd)
          n1: 8208 0x53B72B: gc_init (in /home/dmitry/Dscanner/dscanner-dmd)
           n1: 8208 0x51E710: _

....

So I guess your Mr. X is D's GC that reserves about 1Mb at start.

-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list