Profiling the memory in D

Erdem kerdemdemir at gmail.com
Wed Dec 4 08:10:27 UTC 2019


I am used to have cool tools like valgrid massif to visualize the 
memory usage from C++ but in D it seems I am blind folded looking 
for the problem.

Until now I tried:

--vgc option which show million things which makes it not useful
--build=profile-gc
which seems to slow down my program like *200 times and I have 
some operation depending on time which makes creating the real 
case of the application impossible. The observation itself effect 
the experiment very badly.

Since this options are not useful for me, I tried to put debug 
logs in critical places to estimate where I am losing memory. I 
couldn't find a D native call to get the memory usage of the 
program. I had to call a shell command which also slows down the 
app. This slow down causes me to not be able to put this debug 
log too many places or in critical loops.

I manage to narrow it down a bit. Than I wanted to check the 
object instances to find out which objects are getting bigger. I 
tried
GC.sizeOf(&object) which always prints 0. GC.sizeOf also does not 
works with associative arrays , I don't see any usefull case than 
GC.sizeOf(array.ptr).

That is the background of my questions and my questions are:

Is there a better way to visualize the memory in D something like 
valgrid massif?

profile-gc literally makes to program not do anything due to slow 
down is there any way to profile-gc in a faster fashion?

Is there a native function which will return the memory usage of 
my program?

Is there a function to return sizes of AAs and even class 
instances ?

Erdemdem





More information about the Digitalmars-d-learn mailing list