问题描述
有关,我会粉饰的原因,我需要预留一个固定大小的空间,然后使用boost序列化存储对象那里。存档格式的选择是任意的,便携性是不是一个问题。
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.
有没有人有值得大小估测,他们的信任?空间是很重要的,但它不是在premium。我在寻找相对简单的答案,如2 *(sizeof的X)二进制或4 *成员号码+ 3 * sizeof的(X),如果你喜欢的文字档案。
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".
感谢
推荐答案
没有回应,所以这里就是实验显示。
No responses, so here's what experimentation showed.
从我们的应用程序中,一个类有190件,的sizeof(A)= 12704.这是一个有点害羞的实际总规模因指针。
From our application, one class had ~190 members, sizeof(A) = 12704. That's a little shy of actual total size due to pointers.
binary_oarchive的大小是13981和text_oarchive是21237.这是默认的特点,并配有半打派生类型的档案登记了。
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.
所以,我将使用2 * sizeof的(A)为上限的文本文档,也许1.5 *的二进制。
So, I'm going to use 2*sizeof(A) as an upper bound for a text archive, and maybe 1.5* for a binary.
这篇关于经验法则:与原来的序列化对象提振档案大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!