boost进程间容器中的boost进程间错误

boost interprocess error in boost interprocess containers

本文关键字:boost 进程 错误      更新时间:2023-10-16

我有一个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]: Assertion privat_is_allocated_block(块)'失败。`

总共有6个进程写入该矢量,一个进程弹出数据。

问题:

  1. 访问共享内存的进程数量是否有任何限制,尤其是提升托管容器
  2. 我所理解的是,段管理器和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;
  1. 没有没有限制

你没有提到任何锁。我想这可以解释你的问题。

多个进程同时访问共享资源需要与多个线程相同的访问同步量。当然,不同之处在于,您使用进程间同步对象