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]

Re: vector<> can probably never grow to it's maximum size!


On Tue, 2004-10-19 at 20:44, Paolo Carlini wrote:
> Dhruv Matani wrote:
> 
> >And tries to explain more concretely what I'm trying to achieve and also
> >shows that it's do able in current C++.
> >
> Why you keep on refusing to deal with one issue at a time?
> 
> The below cannot fix, not even in principle, the immediate problem that
> we have with __len overflowing size_type: all the new tricks in __mt_alloc
> are not in effect in this case, ::operator new for sure will never return
> an address == _M_start (half the memory is already used), it will always
> throw, even if you ask only for __old_size + 1. 

Actually, I think this would be useful after all. Consider the situation
where th vector already has 1.2GB of memory, and wishes to expand more.
Consider that the user does a push_back(). Now, the vector will try to
allocate 1.2*2=2.4GB of memory. Currently, I think Linux supports only
3GB data segment(heap) max.

The push_back will throw even though it could have succeeded!
With the patched allocator, it will now try to allocate slightly more
than 1.2GB, and will succeed. Thus, we have presented a
function(push_back) from failing.


> Don't try to achieve the
> impossible, concentrate on the case of small memory allocations, managed
> via mt_alloc memory pools: in that case there is rooom for improvement..
> 
> Paolo.
-- 
        -Dhruv Matani.
http://www.geocities.com/dhruvbird/

The price of freedom is responsibility, but it's a bargain, because
freedom is priceless. ~ Hugh Downs


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]