[cfe-dev] clang memory usage with C++ template metaprogramming

Douglas Gregor dgregor at apple.com
Tue Jun 8 15:03:57 PDT 2010


On Jun 8, 2010, at 2:55 PM, John Bytheway wrote:

> Several years ago I embarked on a project involving some heavy-duty C++
> template metaprogramming.  In the end I abandoned it because the compile
> times and memory usage with g++ were too big.
> 
> On seeing clang's promised reduction of such requirements, I thought I'd
> go back to my project and see how clang fared when compiling it.
> Although it does indeed run much faster than g++, it actually uses
> *more* memory.  I'm just posting here to ask if this is to be expected.
> If it might be indicative of some issue or if you'd like to know where
> all this memory is being used then I'd be happy to try some profiling.
> 
> Here are some numbers for one particular compilation:
> 
> g++ 4.3.3:
>  Wall clock time: 9:38.92
>  Peak memory usage: ~1.40GiB
> 
> g++ 4.4.3:
>  Wall clock time: 7:01.17
>  Peak memory usage: ~1.37GiB
> 
> clang++ (svn r105478):
>  Wall clock time: 0:15.59
>  Peak memory usage: ~1.50GiB

I've also seen this with template metaprogramming-heavy code, but aside from some idle speculation (we think it has to do with type-location information in Clang), we haven't looked into it closely.

	- Doug



More information about the cfe-dev mailing list