|
Boost Users : |
Subject: [Boost-users] Managed shared memory size restrictions
From: Veranika Liaukevich (veronika.levkevich_at_[hidden])
Date: 2015-05-14 08:39:20
Hello everybody,
Is there any restriction to the size of managed shared memory regions?
Should it be in multiples of the page size? I did not manage to find any
relevant information in the documentation, but managed_shared_memory
creation and managed_shared_memory::grow sometimes fail with small
memory sizes specified.
Examples:
1) When I create a managed_shared_memory segment with size 40, the
creation fails with interprocess_exception::library_error.
2) I created managed_shared_memory with initial size 1000, then
increased the size by 24 bytes, I got this:
/usr/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp:514: void
boost::interprocess::rbtree_best_fit<MutexFamily, VoidMutex,
MemAlignment>::grow(boost::interprocess::rbtree_best_fit<MutexFamily,
VoidMutex, MemAlignment>::size_type) [with MutexFamily =
boost::interprocess::mutex_family; VoidPointer =
boost::interprocess::offset_ptr<void>; long unsigned int MemAlignment =
0ul; boost::interprocess::rbtree_best_fit<MutexFamily, VoidMutex,
MemAlignment>::size_type = long unsigned int]: Assertion
`new_block->m_size >= BlockCtrlUnits' failed.
Aborted (core dumped)
I use boost 1.55.0 on Ubuntu 14.04 64bit.
Code used for testing:
#include <boost/interprocess/managed_shared_memory.hpp>
const char *shmname = "MyBoostShmTest";
// Usage: ./progname [init-memory-size] [grow-memory-size]
int main(int argc, char **argv) {
using namespace boost::interprocess;
struct shm_remove {
shm_remove() { shared_memory_object::remove(shmname); }
~shm_remove(){ shared_memory_object::remove(shmname); }
} remover;
size_t size = atoi(argv[1]);
size_t grow_size = atoi(argv[2]);
{
managed_shared_memory segment(create_only, shmname, size);
}
{
managed_shared_memory::grow(shmname, grow_size);
}
return 0;
}
Thanks,
Veranika
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net