I'm new to boost memory pool. I have two questions:
1) My program has multiple iterations. In each iteration, I need to allocate chunks(objects) from a pool. I don't need to allocate array of chunks. I don't free objects until the end of an iteration. Then what is the most efficient way to do that? I wrote the following code, but I'm not sure it is right.
boost::pool<> p(sizeof(MyType));
for (...) {
...
// many calls to p.malloc();
...
p.release_memory(); // Is it OK???
}
Also, I was wondering, to improve locality, how to reuse the memory in the next iteration, instead of deallocating/allocating memory again and again.
2) How to inquiry a pool to know have many objects have been allocated from the pool? For example, if malloc() 2 times, free() 1 time, then the count is 1. Does boost pool have this interface?
Thanks!
-- Junchao Zhang