Boost logo

Boost :

Subject: Re: [boost] Need urgent help >> How to Handle Fragmentation in Boost's managed_shared_memory
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2017-08-17 17:05:52

On 08/17/17 19:22, vijay sharma via Boost wrote:
> I am using Boost::managed_shared_memory for my project. For allocate and
> deallocate we are using boost APIs as show in below example:
> shm_controller.reset(new boost::interprocess::managed_shared_memory(
> boost::interprocess::open_or_create, shmName, size));void * addr =
> shm_controller->allocate(size) ;
> shm_controller ->deallocate(addr);
> For this I have two question:
> 1) How can i handle fragmentation in this ? We are doing very frequent
> allocation and release.

I don't think there are any built-in methods to defragment shared memory
in Boost.Interprocess. You could probably implement something yourself
by iterating over the allocated objects and copying them to another
segment. I haven't done this and not sure if this is possible or how
difficult it is.

> 2) What kind of allocation we are using in boost (slab, slub, slob) ?

It depends on what allocation algorithm you're using. Boost.Interprocess
provides rbtree_best_fit (rb-tree based) and simple_seq_fit (linked list

managed_shared_memory uses rbtree_best_fit.

Boost list run by bdawes at, gregod at, cpdaniel at, john at