Boost logo

Boost Users :

Subject: Re: [Boost-users] Problems with De/Serializing data structures with dll
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-07-03 12:12:15


As I said - two solutions

a) real simple - just increase the call stack. But this would mean that
there might be problems with structures with indirection which goes too
deep.
b) use a system similar to the serialization of std::list which serializes
only the data but rebuilds the links when the data is loaded.

Robert Ramey

Grimm wrote:
> Robert Ramey wrote:
>>
>>
>> This has nothing to do with dlls etc. The problem is actually quite
>> simple:
>> ...
>>
>> a) Your data structure is a loooong linked list of pointers.
>> b) Serialization of the first pointer in the list is going to
>> recursively serialize all the objects in the list.
>> c) subsequent serialization of any previously serialized ones
>> will be optimized away.
>>
>> If you want to do this in this way, The obvious way would
>> be to make sure there's enough stack space. Remember
>> that serialization is a recurrsive process. If you really
>> need to serialize an arbitrarily long linked list, you'll
>> have to think of another way. You might want to look
>> at the implementation of serialization for std::list in the
>> library which serializes the data but reconstructs the links
>> on load (using push back) rather than serializating them. This
>> was done not to avoid this problem but rather because
>> it made use of the public interface of std::list.
>>
>> Robert Ramey
>>
>> P.S. Usage of export often cause "weird linking errors"
>> do to the need to explicitly instantiate code not referred
>> to by name. One then has to invest some effort in thinking
>> about getting stuff serialized. This conflicts with the goal of the
>> library
>> to permit usage of serialization by those who have a lot
>> of other stuff to do.
>>
>> RR.
>>
>>
>
> Thanks for your reply Robert!
>
> I thought a while the problem could be call stack(as the error
> message says :), but actually couldn't believe it will get full with
> 114 cells(with this platform). The reason I mentioned dlls was that I
> thought the problem could something to do with memory management of
> dlls( I'm quite noob with dlls also).
>
> But as I mentioned before linked list is not the issue in this. I
> used it as a simple test code.
>
> The purpose is to use the de/serialization to save/load the data
> content of our software and list(neither any other stl-container) is
> not suitable for this purpose. It is more tree-like structure which
> doesn't fit in easily in stl-containers. The amount of data can be
> really large and some meta data is needed if we use the solution
> which saves only the nodes/leafs of the tree and while loading set
> the cell's pointers right. Reconstruction will be difficult with meta
> data also.
>
> So it seems that the only solution to do the boost::de/serialization
> of large/huge self-made data structures easily is increase the size
> of call stack?
>
> Ps: Sorry about the "weird linking errors". I thought export could
> help me with this one and tried to give a hint I've also tried export.


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