Boost logo

Boost Users :

Subject: [Boost-users] boost serialize - stack overflow for large problems
From: Jörg F. Unger (j-unger_at_[hidden])
Date: 2010-09-28 10:49:47


  I have implemented the serialization routine for a rather complex
structure with many nested classes. The serialization seems to work for
small examples, however, for bigger data sets, I get a stack overflow
error. If I increase the stack size from 8MB to 20MB, the examples seems
to work. However, I'd like to optimize the code the way that I do not
need to increase the stack size (especially, since not all users can do
that themselves)

So here are my questions:
1. Why is the required stack size different for different data sets
different. The structure of the datasets is identical, only the number
of data sets differs - so why is the recursive level different? The only
thing I can imagine is, that I have a class (container) with a vector of
objects. Each object stores a pointer to the container class. Is it
possible that once serialization in the container class starts, that
there is a recursive serialization pattern? This seems to be support by
the fact that the objects in the container class are not serialized in
the same way as they are stored in the container.

class container
{
std::vector<object*> myObjects;
};

class object
{
const container* myContainer;
}

2. How can I try to decrease the required stack size for the
serialization routines and is there a way to estimate the required stack
size for a specific problem a priori, so that I can throw an exception
with an error message manually instead of having a segmentation fault.

Thanks for any suggestions
JFU


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net