Search code examples
c++linuxboostg++boost-build

Reduce memory usage in boost build


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.


Solution

  • 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.