Boost logo

Boost Users :

Subject: Re: [Boost-users] Interprocess : vectors of vectors
From: Jan Herrmann (jherrmann79_at_[hidden])
Date: 2013-05-14 09:48:42


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<int, Mngr> ShMemIntAllocator;
> typedef vector<int, ShMemIntAllocator> 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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net