Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.15.1, 6.0.0 RC
-
-
c2839843f23fb5c289175cb9577981d48dd273fc
Description
Since 5.14 'receiver' QObjects will, on destruction, move its connection in the 'sender' object to an orphaned list, due for cleanup later.
The orphan list is cleaned up on the sender's next signal emission, or on its destruction.
In certain circumstances the sender object rarely or never emits signals, and is long-lived. This leads to a long-lived soft leak every time a connection is made to it.
Can be seen with this example, which is a reduced example of what happens in QNetworkAccessManager:
int main(int argc, char* argv[]) { QCoreApplication qapp(argc, argv); QThread th; th.start(); for (int i = 0; i < 1'000'000; ++i) { QObject *o = new QObject; QObject::connect(&th, &QThread::finished, o, &QObject::deleteLater); o->moveToThread(&th); QMetaObject::invokeMethod(o, &QObject::deleteLater); QThread::msleep(10); } return 0; }
Attachments
Issue Links
- duplicates
-
QTBUG-87774 QToolBar::clear() leaks memory
- Closed
- is duplicated by
-
QTBUG-90576 Possible memory leak in TextInput
- Closed
- is required for
-
QTBUG-86368 QQmlContext leak when connecting to and destroying dynamically created object
- Closed
-
QTBUG-88063 Memory leak in QNetworkAccessManager from QMetaObjectPrivate::connect
- Closed
-
QTBUG-88587 QQuickWidget object stay in QML Engine cache after deletion
- Closed
- relates to
-
QTBUG-90576 Possible memory leak in TextInput
- Closed
- resulted in
-
QTBUG-106025 REG: isSignalConnected creates a dead lock.
- Closed