Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 556
cyberguijarro Avatar asked May 04 '13 07:05

cyberguijarro


1 Answers

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.

like image 197
Ahmed Masud Avatar answered Oct 23 '22 01:10

Ahmed Masud