[Qt-interest] QQueue / QList memory allocation behaviour

Constantin Makshin cmakshin at gmail.com
Fri May 27 20:50:11 CEST 2011


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().

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110527/fcf28e6d/attachment.bin 


More information about the Qt-interest-old mailing list