memory allocation in dmd

Don turnyourkidsintocash at nospam.com
Tue Jul 2 03:30:54 PDT 2013


On Saturday, 22 June 2013 at 21:41:15 UTC, Walter Bright wrote:
> Compiling std.algorithm for unittests consumes all the memory 
> on many machines. I've been looking into what is allocating all 
> that memory, and it isn't so easy without adding 
> instrumentation code anywhere.
>
> Anyone know of a convenient tool to do this on Linux?
>
> (valgrind just hangs, or at least I gave up on it after 6 hours)

I did a check on the CTFE part of it. You can do this by setting 
SHOWPERFORMANCE to 1 in the top of interpret.c. This produces:

$ dmd -c -unittest std.algorithm
         ---- CTFE Performance ----
max call depth = 20	max stack = 63
array allocs = 356	assignments = 45356

That's actually not so terrible. The number of assignments gives 
a rough idea of how many CTFE statements are executed (almost 
everything interesting is an assignment). Most of the assignments 
are IntegerExpressions, of about 8 bytes, so it's under a 
megabyte in total. Note that there are very few array 
allocations, they are the thing that can really chew up memory 
quickly in CTFE.

So although CTFE generally leaks memory like the Exxon Valdez 
leaks oil, I don't think it's to blame in this particular case.


More information about the Digitalmars-d mailing list