memory allocation in dmd
Richard Webb
richard.webb at boldonjames.com
Thu Jul 4 03:04:18 PDT 2013
On 02/07/2013 11:30, Don wrote:
>
> $ 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.
I had another go at running memory validator on an MSVC build of the
latest source, and that says that there are 619008 instances of
IntegerExp, at 30 bytes each (it's the 3rd most numerous named object,
though only uses 2.3% of the memory).
I'm not sure how accurate that is as the wrapping of malloc etc in DMD
confuse the results - e.g. it just lists 2159119 instances of
'rmem.c:46' rather than saying what they actually are.
fwiw, it says there are 14,828,139 allocations totalling 814.7MB from
'-c 'unittest' algorithm.d .
More information about the Digitalmars-d
mailing list