does pool::release_memory() really require an ordered pool?

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 lot of memory, but then later (after spiking) I'd like to release it. (The object pools will persist for the life of the application, and there will probably always be some "active objects" -- i.e., allocated from the pool and not free()d yet.) (I'm hoping the documentation may be out of date, and release_memory() can be used on pools that don't use ordered_malloc() and on object_pools.) -- Mark

Zitat von Mark Rajcok
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.
participants (2)
-
Mark Rajcok
-
Stefan Strasser