[Qt-interest] QFutureWatcher memory leak

Антон Сердюков uksus70 at gmail.com
Wed Jun 17 08:34:47 CEST 2009


Good day.

I suppose I have found a memory leak caused by QFutureWatcher.

I have one permanent QFutureWatcher object, which is populated with QFuture
instance. This QFuture is returned by QtConcurrent::run. Upon first future
finishes, the result is obtained from it and QFutureWatcher is populated
with another similar QFuture. And so on. The result of the calculation is a
big QByteArray.

Attention, the moment of leakage. The memory is consumed and never released.
Seems like QFutureWatcher::setFuture does not decrease reference counter of
previous QFuture and it remains in memory.
If one destroys QFutureWatcher every iteration and creates another one each
time, then leak does not appear.

The simplest sample program is attached.

Regards,
Anthony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090617/678a0587/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FutureSample.zip
Type: application/zip
Size: 956 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090617/678a0587/attachment.zip 


More information about the Qt-interest-old mailing list