Yes, I printed a qDebug message on the MessageThread destructor when it is deleted and saw that the destructor is being called.
Yes, I printed a qDebug message on the MessageThread destructor when it is deleted and saw that the destructor is being called.
And the QTcpSocket/QSslSocket you create in MessageThread, are those deleted? Also, have you tried running with valgrind?
I am getting into the valgrind tool right now.
About the QSslSocket, yes I am deleting it.
One thing that decreased the memory leak noticeably (but not at all) is moving the following code from the "performCleanExit" function in the thread:
Qt Code:
m_socket->deleteLater(); m_authTimer->deleteLater();To copy to clipboard, switch view to plain text mode
to the following code in thread destructor:
Qt Code:
delete m_socket; delete m_authTimer;To copy to clipboard, switch view to plain text mode
It may be related to that that the deleteLater() function does not enter the event loop (in order to be executed) before the thread is deleted.
I will make further investigation and try to provide the client code as well in order to be able to reproduce the memory leak easily.
Thanks in advance
Hello, i`ll watch that thread closely for your final investigation about the memory leak. I`ve got the same problem with a multithreaded QSslSocket app myself and the memory of my server app goes up like ~700kb per client connect/disconnect. And my code is similar to yours.
By the way, I am using QT version 4.6.2.
There is a reported bug about QSslSocket memory leak in the following link: http://bugreports.qt.nokia.com/browse/QTBUG-6504
I do not know whether or not this the problem I am having here.
Regards
Finally I found the code causing the memory leak:
In the server side, setting the private key causes a memory leak. It seems like a bug in QT.
The code that causes the memory leak is:
Qt Code:
m_socket->setPrivateKey(":/certs/my-key.pem"); // Add the key that will make the handshake m_socket->setLocalCertificate(":/certs/my-cert.pem");To copy to clipboard, switch view to plain text mode
I think this is the bug reported:
http://bugreports.qt.nokia.com/browse/QTBUG-6504
Bookmarks