Boost logo

Boost :

From: Grimm, Matthias (matthias.grimm_at_[hidden])
Date: 2021-03-12 14:41:48


Hi,

I have a question regarding the interprocess library and the use of shared memories.

When creating a boost::interprocess::managed_shared_memory it seems to be necessary to take some additional space into account. In my case the following approach works well:

managed_shm = new ip::managed_shared_memory(ip::create_only, "shm_id",
        (vec_elems + 110) * (number_of_samples + 1));

Following this it seems to be necessary to always have one additional element. If I remove the additional element

(vec_elems + 110) * (number_of_samples)

an exception is thrown: boost::interprocess::bad_alloc. This is also the case if I change to

(vec_elems) * (number_of_samples + 1)

Does anybody know why it is necessary to have this additional space allocated? What is the exact minimum size to avoid the exception? The additional memory may become a problem if the size of the vector elements is large.

Attached you'll find some example code. Any help on this topic would be appreciated.




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk