On 14.05.2013 15:09, Oodini wrote:
I am studybing this point. If you construct an empty vector in a managed shared memory, you have already 152 bytes consumed. I'd like to be sure that this value is always same.
Correction. By applying the function get_free_memory(), I can see that as soon as you create the managed shared memory, you lose some bytes :
typedef allocator
ShMemIntAllocator; typedef vector MyVector;managed_shared_memory shmem(create_only, "name", 65536); // shmem.get_free_memory() = 65384 -=> 152 bytes have been used MyVector* vv = shmem.construct<MyVector>("Vector")(shmem.get_segment_manager()); // shmem.get_free_memory() = 65296-=> 88 bytes have been used
On Visual Studio 2010, an empty vector consumes 40 bytes.
Why not simply try different matrices with some larger memory segments, measure needed size and create a heuristic like: size=serialized_size*factor+extra_memory which full fills your need. Additionally I would avoid reallocations (no push_back) of vector inside shared memory to avoid fragmentation. Jan Herrmann