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

John Bytheway jbytheway+llvm at gmail.com
Tue Jun 8 14:55:04 PDT 2010


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

TBH I'm astonished that clang was able to gobble up so much memory in so
little time!

John Bytheway





More information about the cfe-dev mailing list