【发布时间】:2015-09-14 11:02:34
【问题描述】:
我有一个 boost 进程间向量,其中包含字符串 (boost::interprocess::basic_string) 作为保存在共享内存中的值,从长远来看,我会收到此错误
include/boost/interprocess/mem_algo/rbtree_best_fit.hpp:1346: void boost::interprocess::rbtree_best_fit<MutexFamily, VoidMutex, MemAlignment>::priv_deallocate(void*) [with MutexFamily = boost::interprocess::mutex_family; VoidPointer = boost::interprocess::offset_ptr<void>; long unsigned int MemAlignment = 0ul]: Assertionpriv_is_allocated_block(block)' 失败。`
共有 6 个进程写入该向量,一个进程弹出数据。
问题:
- 访问共享内存的进程数量是否有任何限制,尤其是 boost 托管容器。
- 我的理解是段管理器和mem算法是保存在共享内存中的,对吗?
我使用这个类:
class SharedVector {
public:
boost::interprocess::interprocess_mutex mutex;
complex_vect_type m_vect;
SharedVector(const void_allocator &a) : m_vect(a) {}
};
为了创造,我正在这样做:
memsegment->construct<SharedVector>("sharedvector") (*m_allocator);
并且在另一个进程中这样做是为了访问它
mem_segment->find<SharedVector>(t"sharedvector").first;
【问题讨论】:
-
class SharedVector { public: boost::interprocess::interprocess_mutex mutex; complex_vect_type m_vect; SharedVector(const void_allocator &a) : m_vect(a) { } }并且为了创建我正在这样做:memsegment->construct<SharedVector>("sharedvector") (*m_allocator);并且在另一个过程中我正在这样做以访问它mem_segment->find<SharedVector>(t"sharedvector").first;
标签: c++ boost interprocess boost-interprocess