Hi ,
I am writting an c++ boost shared memory application.
The string/char class works fine . But the allocation to int phases some problem.
It works fine for a while bt suddenly shared memory crashes. Unable to access it.
here is a small snippet.
we have to create a shared memory. it ll contain a map (int as key , int vector as value)
typedef managed_shared_memory::segment_manager SegmentManager;
typedef int KeyType;
//int type vector in share Memory
typedef allocator<int,SegmentManager> IntAllocator;
typedef boost::interprocess::vector<int ,IntAllocator> MyShmIntVector;
//For Map
//Map of type <int , vector<int> >
typedef std::pair<const int,MyShmIntVector>IntValueType;
typedef allocator<IntValueType,managed_shared_memory::segment_manager>ShmIntAllocator;
typedef map<KeyType,MyShmIntVector,std::less<KeyType>, ShmIntAllocator> MapCountIntData;
//Iterators For int vector and Map(Int Type)
MapCountIntData::iterator intmapit;
MyShmIntVector::iterator intvecit;
and the functions to create it is lik..
shared_memory_object::remove(name);
managed_shared_memory shm(create_only ,name,size); //segment size in bytes
//Checking for Index Value 0,1 or 2
ShmIntAllocator intalloc(shm.get_segment_manager());
MyShmIntVector *myintvector1 = shm.construct<MyShmIntVector>("MyShmIntVector")(intalloc);
//ShmIntAllocator alloc_inst(shm.get_segment_manager());
ShmIntAllocator alloc_inst(shm.get_segment_manager());
MapCountIntData *mymap = shm.construct<MapCountIntData>("MapCountIntData")(std::less<KeyType>(),alloc_inst);
//managed_shared_memory::grow(name,60);
//Intializing vector with 0;
for (int veccnt=0; veccnt<3; veccnt++)
myintvector1->push_back(0);
mymap->insert(std::pair<int,MyShmIntVector>(key,*myintvector1));
do u find nething mising regarding to allocation
thanks for help,
Suman