views:

21

answers:

1

For reasons that I will gloss over, I need to set aside space of a fixed size, and then use boost serialization to store an object there. The choice of archive format is arbitrary, and portability is not a concern.

The class is fairly complex (members include fundamental types, arrays, pointers, and child classes) and guaranteed to grow over time.

Does anyone have worthwhile sizing guestimates they trust? Space is important, but it's not at a premium. I'm looking for relatively simple answers like "2*(sizeof X) for binary" or "4 * number of members + 3*sizeof(X) if you like text archives".

Thanks

+1  A: 

No responses, so here's what experimentation showed.

From our application, one class had ~190 members, sizeof(A) = 12704. That's a little shy of actual total size due to pointers.

Size of binary_oarchive was 13981 and text_oarchive was 21237. This was for default traits, and an archive with a half-dozen derived types registered too.

So, I'm going to use 2*sizeof(A) as an upper bound for a text archive, and maybe 1.5* for a binary.

Rick Berge