I'm using Boost Interprocess to map a vector in shared memory.
This is the code I have from Boost tutorials:
using namespace boost::interprocess;
using ShmemAllocator = allocator<int, managed_shared_memory::segment_manager>;
using MyVector = boost::interprocess::vector<int, ShmemAllocator> MyVector;
// question refers to this size
// V
managed_shared_memory segment(open_or_create, "MySharedMemory", 65536);
const ShmemAllocator alloc_inst (segment.get_segment_manager());
MyVector *myvector = segment.construct<MyVector>("MyVector")(alloc_inst);
myvector->resize(SIZE);
I resize my vector after creating the managed_shared_memory
.
However, what happens if the managed_shared_memory
size argument is smaller than the vector memory allocation?
Rewording the question: how do I choose a size for the managed_shared_memory
?