Boost logo

Boost :

From: Steve Kettle (skettle2000_at_[hidden])
Date: 2007-08-14 18:14:26


I have a question about the memory pool allocation that boost implements. Suppose we do the following:
   std::vector<int, boost::pool_allocator<int> > v;
   for (int i = 0; i < 10; ++i)
     v.push_back(-1);
 
And the std::vector<int> is implemented so that it starts out with
 reserved space of 1 and doubles space every time. So At the end of the above loop v will have size 10 and reserved size 16.
 
Does the boost allocator mean that there will memory arrays lieing
 around of size 1,2,4,8 that can be reused ?
 
Eg if you do this:
 
  std::vector<int, boost::pool_allocator<int> > v;
   for (int i = 0; i < 10; ++i)
     v.push_back(-1);
 
  std::vector<int, boost::pool_allocator<int> > v2;
   for (int i = 0; i < 8; ++i)
     v2.push_back(-1);
 
There will be no system call needed to get more memory -
 v2 will just reuse the memory in the pool_allocator<int> ?
    
   Thanks.
Steve.

       
---------------------------------
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk