From: Geoff Leyland (geoff.leyland_at_[hidden])
Date: 2002-11-08 03:33:14
I'm using boost::pool for (evidently) allocating memory for a whole
bunch of objects (thanks Stephen Cleary for pool). Most of the time the
objects are entirely independent, however, from time to time, I'd like
to iterate through all the allocated objects (in this case to generate
some test statistics over then). To do this I keep a list of pointers
to everything I've allocated. The time spent keeping this list up to
date, particularly removing an object, is significant.
One possible (and very nice fix) would be to have a pool_iterator that
let me, as I said, iterated through the allocated objects. As far as I
can tell, this doesn't exist. Does anyone have any comments on whether
this is a good idea, whether it's feasible, and perhaps how I might go
The pools don't seem to have a bit-map of free blocks - and traversing
the free list at every increment would be horribly slow. I have a
"holey_vector" that uses a vector as storage, and keeps a sorted list of
free indexes, but I can't imagine this approach would work in a pool,
where the storage is a list of blocks at non-increasing addresses.
Marking blocks as free at the beginning of the block would take up at
worst a whole alignment worth of memory, kind of defeating the point of
So I'm guessing the best approach would be a bit map of free blocks.
-- Geoff Leyland Laboratoire d'energetique industrielle LENI-DGM-EPFL, CH-1015, Lausanne, Switzerland Phone: +41 (21) 693 3505, Fax: +41 (21) 693 35 02
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk