7

I'm trying to build a C++ library on a linux system with constrained memory resources, using G++ 4.6. The library uses Boost heavily.

I've seen various threads here and in other websites regarding compilation speed, but I'm interested in tips and tricks to make G++ less demanding on memory resources, even though it means loosing speed.

EDIT: I've tried using precompiled headers for Boost, which improves only build speed, but still requires roughly the same amount of memory.

TemplateRex
  • 69,038
  • 19
  • 164
  • 304
cyberguijarro
  • 715
  • 3
  • 9
  • 21
  • 1
    It sounds like you are trying to build on an embedded platform. This is generally not a good idea. Instead use cross-compilation from a platform that's not constrained in the same way, and transfer the program to the platform after it's built. – Some programmer dude May 04 '13 at 08:05
  • I'm afraid it's not possible without changing this library implementation, in particular the way it uses `boost`. High memory usage at compile-time usually means that there are a lot of template instantiations. – Igor R. May 04 '13 at 17:42
  • @JoachimPileborg No. We just have a very modest server a no resources to upgrade it. – cyberguijarro May 05 '13 at 11:46

1 Answers1

6

You have to play with the garbage collector settings. The parameters are ggc-min-expand and ggc-min-heapsize. Also set your ulimit with ulimit 65536 (or whatever) to reduce the heap size (RLIMIT_AS).

Lots of information on that in the gcc manual here

A good setting may be to set the ggc-min-expand param to 0 and ggc-min-heapsize param to 8192 and try with that...

CXXFLAGS="$(CXXFLAGS) --param ggc-min-expand=0 --param ggc-min-heapsize=8192" or some such value.

Ahmed Masud
  • 21,655
  • 3
  • 33
  • 58