Re: [Boost-users] [serialization]save/load objects to/from a block of memory?
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
participants (1)
-
Jasper, Alexander