On Thursday, August 24, 2006 at 07:33:01 (-0700) smith smithson writes:
I'm trying to use boost serialization to serialize/deserialize data to and from a mmap'd file. I have my own ostream/istream classes that essentially read/write bytes from a mmap'd file. The process works fine except on some rare occasions (With different objects/number of objects), in which case boost throws a "stream error" exception. Any ideas what could trigger this? A search of the Boost archives indicated other people had the same problem, where the solution was "use binary mode when you open the file"... but I'm not using a file on disk, I'm using a mmap'd file. (As a side note, the mmap file is large enough to hold all my data and does not need to be expanded or remmap'd etc)
The OS i'm using is Linux.
Thanks for any suggestions...
I don't use my own mmap classes, I use boost's, under Linux: boost::iostreams::streamboost::iostreams::mapped_file_source ifs(filename); if (compress) { boost::iostreams::filtering_istream in; in.push(boost::iostreams::zlib_decompressor()); in.push(ifs); Archive ia(in); ia >> BOOST_SERIALIZATION_NVP(obj); } else { Archive ia(ifs); ia >> BOOST_SERIALIZATION_NVP(obj); } And it works fine. I do not use it for the write side, as I don't know in advance how large the object will be, etc. I would suggest a few runs with standard streams to see if you still get the error. Boost is independent (should be) of the stream used, so that would be a good test. Bill