Reduce memory usage in boost build
Asked Answered
C

1

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.

Codie answered 4/5, 2013 at 7:51 Comment(3)
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.Dumbbell
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.Agnosticism
@JoachimPileborg No. We just have a very modest server a no resources to upgrade it.Codie
L
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.

Litmus answered 4/5, 2013 at 8:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.