Hi,
I am using managed_shared_memory in my program. The program runs fine if only one instance is used. However if more than one instance is used then one instance dies randomly.
The instance dies at the following code :
char_string key_object(keyHashStr.c_str(), alloc_inst3);
The sample program is :
-----------------------
#include
#include
#include
#include <string>
#include <iostream>
#define RESERVED_BUFFER_SIZE_WRITE (8 * 0x0100000)
namespace bip = boost::interprocess;
//Typedefs of allocators and containers
typedef bip::allocator char_allocator;
typedef bip::basic_string char_string;
int main()
{
bip::managed_shared_memory m_sharedMemUsage(bip::open_or_create, "MyBookkeeper", 2 * RESERVED_BUFFER_SIZE_WRITE);
char_allocator alloc_inst3(m_sharedMemUsage.get_segment_manager());
for (int count = 0; count < 100000; ++count) {
char_string key_obect("AAAAAAAAAAAAAAAAAAAAAAA", alloc_inst3);
}
}
-----------------------
Please let me know if I am missing something in this program.
Regards,
Abhishek