Details
-
Bug
-
Resolution: Unresolved
-
P4: Low
-
None
-
5.9.2
-
None
-
Windows 10 x64
Qt 5.9.2 (msvc2013_64)
Description
Calling certain Qt functions within a thread which was not created by Qt leads to memory leaks.
The following minimal example reporduces the issue:
#include <QCoreApplication> #include <QThread> #include <QtConcurrent/QtConcurrent> #include <QTimer> #include <future> #include <qt_windows.h> int main(int argc, char *argv[]) { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); QCoreApplication a(argc, argv); QtConcurrent::run(QThread::currentThread).waitForFinished(); // all good, no leak std::async(std::launch::async, QThread::currentThread).get(); // this causes memory leaks QTimer t; QObject::connect(&t, &QTimer::timeout, qApp, &QCoreApplication::quit); t.start(1000); return a.exec(); }
Note that without a QCoreApplication both calls to 'QThread::currentThread()' cause leaks.
With the QCoreApplication and event loop present only the 'std::async' case leaks.