[Qt-interest] QQueue / QList memory allocation behaviour

Sean Harmer sean.harmer at maps-technology.com
Fri May 27 21:27:41 CEST 2011


On Friday 27 May 2011 22:50:11 Constantin Makshin wrote:
> The documentation for QList::reserve() says "If alloc is smaller than the
> current size of the list, nothing will happen."
> 
> IMHO, that's quite logical as the method's name assumes that it'll ensure
> there's enough space for requested amount of items. And obviously this
> assumption is absolutely correct if QList already contains more items than
> passed to reserve().

I stand corrected. In my defence, I did say "I think" ;-)

> 
> On Thursday 26 May 2011 19:57:04 Sean Harmer wrote:
> > On Thursday 26 May 2011 15:41:33 Schimkowitsch Robert wrote:
> > > Thanks for your explanation, and also for the pointer to the
> > > proposed
> > > QCircularBuffer class.
> > > 
> > > One more  question regarding QList behaviour:
> > > If I "reserve" a QList with a specific size, will it still free
> > > memory
> > > when shrinking too much?
> > 
> > No. Only if you later reserve() a smaller amount (I think).
> > 
> > Sean



More information about the Qt-interest-old mailing list