Subject: [Boost-bugs] [Boost C++ Libraries] #4960: boost::pool_allocator for vector of vectors exhausts memory
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-12-07 23:42:34
#4960: boost::pool_allocator for vector of vectors exhausts memory
-------------------------------------+--------------------------------------
Reporter: mattiasg | Owner: cnewbold
Type: Bugs | Status: new
Milestone: To Be Determined | Component: pool
Version: Boost Development Trunk | Severity: Problem
Keywords: |
-------------------------------------+--------------------------------------
glr9940 reported in #386 that using boost::pool_allocator for a vector of
vectors caused problems. I have now found a slight extension to the
example glr9940 reported which does not crash, but exhausts memory even
for a tiny vector of vectors.
I have used the development trunk code and gcc 4.1.2.
{{{#!cpp
#include <boost/pool/pool_alloc.hpp>
#include <vector>
#include <iostream>
typedef std::vector<int, boost::pool_allocator<int> > EventVector;
typedef std::vector<EventVector> IndexVector;
int main()
{
IndexVector iv;
int limit = 100;
for (int i = 0; i < limit; ++i)
iv.push_back(EventVector());
std::cout << "it works\n";
return 0;
}
}}}
I suspect that the critical value for 'limit' depends on the machine. On
my machine a limit of 20 seems to work fine, a limit of 24 uses a few Gb
of memory, while a limit of 30 stalls the process, 'top' showing that the
memory footprint doubles rapidly until memory is exhausted. I've noticed
for other examples of this issue that when I replace the vector push_back
loop with a rolled out version just creating a number of pooled vectors,
it works fine.
Have I made some noob mistake, or is this a bug?
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4960> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:05 UTC