[Qt-interest] QQueue / QList memory allocation behaviour

Sean Harmer sean.harmer at maps-technology.com
Mon May 16 10:20:01 CEST 2011


Hi,

On Monday 16 May 2011 08:13:09 Schimkowitsch Robert wrote:
> I have a QQueue<MyClass*>, or a QList<MyClass*> where I mainly append at
> the end, and remove in front.
> Let's assume I start out with the maximum size of Queue or List, and
> then let it shrink and grow as needed, but never beyond the original
> size.
> 
> Will it perform new and delete operations continuously, once in a while,
> or will it only re-use already allocated memory?
> 
> The question behind this: Will I create memory fragmentation when using
> QQueue / QList in this fashion in multiple threads?

The QCircularBuffer container class that I have written for Qt sounds as if it 
would be a good fit for you here. There is a MR for it at:

https://qt.gitorious.org/qt/qt/merge_requests/2364

It applies cleanly against the Qt git 4.8 branch (and should do against master 
too). The MR includes full docs and a unit test.

Cheers,

Sean

ps If it is useful to you then please add a comment to the MR to increase the 
chances that somebody will get around to reviewing it one day.




More information about the Qt-interest-old mailing list