|
Boost Users : |
From: Jasper, Alexander (alexander.jasper_at_[hidden])
Date: 2005-08-16 03:25:20
Hi!
>> Li Lirong wrote:
> > How can I save/load my c++ objects to/from a block of memory using
> > Boost.Serialization? Can anyone give some sample code?
>
> You can simply stream into a std::stringstream:
>
> std::stringstream stream;
> {
> boost::text_oarchive oa(stream);
> oa << my_data;
> }
>
But don't do that with to much data. I tried that with a similar approach, but it didn't work.
It is far better to serialize to a lot of 'small' (e.g. 64K) blocks rather a huge one (100MB) that needs, even worse, to be realloced once and again. This completely fragmented the address space in my app.
Of course this only important, if you are dealing with bigger amounts of data.
If you are interested I could send you my implementation of a stream buffer that uses fixed size blocks.
I'm not completely satisfied with it, though. I still suffers from scalability problems.
kind regards
Alex
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