Boost logo

Boost Users :

Subject: Re: [Boost-users] does pool::release_memory() really require an ordered pool?
From: Stefan Strasser (strasser_at_[hidden])
Date: 2010-09-02 10:29:41


Zitat von Mark Rajcok <mrajcok_at_[hidden]>:

> On page
> http://www.boost.org/doc/libs/1_44_0/libs/pool/doc/interfaces/pool.html
> there is this precondition for release_memory(): "t must be ordered".
>
> Does that mean that ordered_malloc() must always be used, if I want to
> use release_memory()?
>
> Looking at the implementation for release_memory(), it appears to be
> iterating through chunks in each block, which I wouldn't expect if
> ordered_malloc() were always used.
>
> What I'm really after: I want to use object_pool, but periodically
> I'd like to reclaim/release any memory blocks that are no longer in
> use. In my application, I may have traffic spikes, where I allocate a

object pools as defined by Boost.Pool must use ordered_malloc anyway,
because your objects might have destructors and only an ordered pool
can find the allocated objects in case the pool is destructed (e.g. on
exception).
if you need to free many pool objects (but not the entire pool) I'd
recommend not using Boost.Pool at all. ordered_free has a runtime
complexity linear to the size of the free list.

I think Boost.Pool is outdated and Boost.Pool2 might be a good GSOC
project. is anyone maintaining a list?

in the meantime, I'd recommend building your own pool for this use
case using Boost.Intrusive containers.


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