小编Dan*_*ere的帖子

共享内存分配> 2GB(需要链接到VB6使用的32位DLL)

我正在使用 C++ 中 boost 库的共享内存,我试图分配一个 unordered_map 与其他进程共享。服务器端代码如下:

地图创建器.h

//#pragma once
#pragma warning( disable :4494 )
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/string.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/managed_mapped_file.hpp>
#include <boost/functional/hash.hpp>
#include <boost/unordered_map.hpp>
#include <iostream>

struct dataClass {
    double Somma;
    int Contatore;
};

namespace bip = boost::interprocess;
namespace bc = boost::container;
#ifdef COLIRU
using Segment = bip::managed_mapped_file;
#else
using Segment = bip::managed_shared_memory;
#endif
using Mgr = Segment::segment_manager;

template <typename T> using Alloc = bip::allocator<T, Mgr>;
using MyString = bc::basic_string<char, std::char_traits<char>, Alloc<char>>;
using KeyType = MyString;
using …
Run Code Online (Sandbox Code Playgroud)

c++ boost shared-memory visual-studio

2
推荐指数
1
解决办法
180
查看次数

标签 统计

boost ×1

c++ ×1

shared-memory ×1

visual-studio ×1