Boost logo

Boost Users :

Subject: Re: [Boost-users] [Interprocess] Different outputs under bash and gdb
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2010-11-24 10:19:48


On 24/11/2010 15:21, Aditya Gadre wrote:
> Ion,
>
> Thank you for your reply. According to Boost.Interprocess documentation,
> you *can* share std::vector by using managed shared memory and
> Boost.Interprocess allocator (please see "Creating vectors in shared
> memory" in "Quick guide for the impatient" in Boost.Interprocess
> documentation). Following those guidelines and the example therein , I
> have successfully shared std::vector object using following -

Believe me, you can't. The example uses boost::interprocess::vector (see
using namespace boost::interprocess; and not using namespace std;)

http://www.boost.org/doc/libs/1_45_0/doc/html/interprocess/quick_guide.html#interprocess.quick_guide.qg_interprocess_container

you can't share a std::vector because its internal pointers are normally
raw pointers. If two processes map the segment in a different base
address it will crash. If you are lucky and both processes map the
segment in the same address, then it won't crash, but you have no
guarantee for that. For more explanations see:

http://www.boost.org/doc/libs/1_45_0/doc/html/interprocess/allocators_containers.html#interprocess.allocators_containers.containers_explained

Best,

Ion


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