Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
If I do not connect a slot to QNetworkAccessManager::finished() will QNetworkReply objects leak?
philk last edited by
I assume, the QNR object created by the QNAM are created with the QNAM as their parents, so they will not "leak", they will indeed being deleted when their parent QNAM is deleted. However, if noone ever connects a finished slot to the signal, I assume the QNR are still created and kept around for all the lifetime of their parent QNAM. This will increase memory footprint over time. Is my assumption correct?
tomma last edited by
I am pretty sure their deletion is your responsibility. You can connect their finished signal to deleteLater slots to make sure they are not leaked.
[quote author="philk" date="1376174647"]I assume, the QNR object created by the QNAM are created with the QNAM as their parents[/quote]No, they're not. It's in the "documentation":http://qt-project.org/doc/qt-5.1/qtnetwork/qnetworkaccessmanager.html:
[quote]After the request has finished, it is the responsibility of the user to delete the QNetworkReply object at an appropriate time. Do not directly delete it inside the slot connected to finished(). You can use the deleteLater() function.[/quote]