Hi:

I try fast_pool_allocator and it does not release memory.  See the following program
Any ideas?

Thanks!

-Kawasaki

--- Begin ---
 #include <vector>

#include <boost/pool/pool_alloc.hpp>
#include <list>


using namespace std;
using namespace boost;

#include "memusage.cpp"

//--------------------------------------------------
void func()
{

  list<int, fast_pool_allocator<int> > v;
  //  list<int> v;
  for (int i = 0; i < 1000000; ++i) {
    v.push_back(i);
  }

  printf("2. MEM USAGE = %d\n", getMemUsage());

}


//--------------------------------------------------
int main(int argc, char **argv)
{

  printf("1. MEM USAGE = %d\n", getMemUsage());
  func();
  func();
  func();
  /// Exiting the function does NOT free the system memory allocated by the pool allocator
  // You must call
  //  boost::singleton_pool<boost::pool_allocator_tag, sizeof(int)>::release_memory()
  // in order to force that
  printf("3. MEM USAGE = %d\n", getMemUsage());
 
  boost::singleton_pool<boost::fast_pool_allocator_tag, sizeof(int)>::release_memory();
  printf("4. MEM USAGE = %d\n", getMemUsage());
 
  return 1;
 
}

--- END

output

1. MEM USAGE = 11 MB
2. MEM USAGE = 35
2. MEM USAGE = 35
2. MEM USAGE = 35
3. MEM USAGE = 35
4. MEM USAGE = 35  // after release_memory() is called,