我想在几个进程之间使用共享内存,并希望能够继续使用原始指针(和stl容器).
为此,我使用映射在固定地址的共享内存:
segment = new boost::interprocess::managed_shared_memory(
boost::interprocess::open_or_create,
"MySegmentName",
1048576, // alloc size
(void *)0x400000000LL // fixed address
);
Run Code Online (Sandbox Code Playgroud)
选择这个固定地址的好策略是什么?例如,我应该使用一个相当高的数字来减少我用完堆空间的可能性吗?