This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Yes, previously, __simple_alloc::allocate avoided calling _Alloc::allocate when __n == 0. Therefore this intermediate layer took care of avoiding pointless allocations.in the default constructor of the std::vector a zero sized vector is created. If this vector is copied with the copy constructor a memory block of size zero is allocated, resulting in a real memory allocation.
This behavior has changed as the std::allocator changed from a separate implementation to the __glibcxx_base_allocator somewhere around 2004 (we recently changed from gcc 3.3.2 to 4.1.0).
Because we use something like: vector <vector <int> > v; v.resize (1000000);
That gave use a huge bunch of memory allocations :-(
So here are my questions:I think we should do 2), seems doable. I'm looking into it.
1) Is there an easy standard way to change the default allocator? Not per
instance - this would be
way to much to change :-(
2) Is there a chance that the copy constructor of the vector (or the
allocator) will be changed to
the former behavior? (I guess the standard don't say anything about
which of both is correct)
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |