Compilation is taking a ton of memory

Jacob Carlborg doob at me.com
Wed Jul 4 19:24:17 UTC 2018


On 2018-06-27 18:00, Mario Silva wrote:
> Hello,
> 
> Our code base has been growing steadily and it's currently at a point 
> where my 16GB machine just freezes when we're compiling our code. This 
> happens because DMD just consumes all my memory for a while.
> 
> Also, it's taking a long time to compile it. Less than an year ago our 
> project was taking around 17 seconds to compile - no libs requiring 
> compilation - and maybe around 50 seconds for full compilation, and it 
> now takes around 50 seconds for an incremental compilations and around 
> 1.5 minutes for a full one.
> 
> For you guys to have an idea of the size of our project, we have 21151 
> lines of code and then 50933 in our libs. This is just our code without 
> counting dependencies fetched by dub like vibe.d for example.
> 
> Are there any plans to work on compiler performance in terms of memory 
> consumption and compilation time?
> 
> Any tips on how to code in a way that minimizes both compilation times 
> and memory consumption when compiling?

Unless this already has been stated, the issue is usually not the size 
of the project, it's rather which compile time features which are used. 
For example the DWT project has over 200k lines of code and compile (to 
a library) in a couple of seconds. Try to reduce templates and CTFE 
code, if possible and prefer CTFE over templates.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list