On Fri, Jul 29, 2011 at 6:35 PM, Robert Ramey <ramey@rrsd.com> wrote:
I'm going to guess that there's too much instatiation going on.
 
I agree 
 
 Try the
following:
 
a) try changing the headers so they don't inlcude inline functions.  Put
definitions in a separate cpp or ipp file.

Yes, I already have (almost) all inline code outside headers. I'll revise it further.
 
b) since a is a huge amount of work.  Try this:  build your above
module a little at a time.  That is - comment out most of the headers
and try to build - of course it will fail to link.  Add headers until
it starts to have the problem.  The basic goal is to find which
templates are being "accdently instantiated multiple times.

Doing as you wisely suggest, I noticed that the compiler's heap seems to blow up when trying to produce code for template member function "serialize" of some specific classes, which are are roots of containment structures made out of lists, vectors and maps of shared_ptr to other objects, which are in turn a composition of other objects. The containment structures is 3-4 levels deep. Think of it as a "Sketch" root object, containing a list of shared_ptr to "Polyline", each containing a list of shared_ptr to "LineSegment" or "ArcSegment", each containing a pair of "Point" and some more data. When the compiler parses/generates code for "Sketch::serialize", about two gigabytes of memory are allocated.

I found a workaround, anyway, tweaking some compiler optimizations. I also revised all the header files and moved some code outside, then isolated all BOOST_CLASS_EXPORT_IMPLEMENTs in one .cpp and moved any other serialization code in other two cpp. This seems to have solved my problem.

Unfortunately, I haven't found a more effective strategy for reducing code bloat, so I am ready to accept/try any further advice in this regard.

Thanks again for your advices.
Enrico