Results 1 to 9 of 9

Thread: Memory leak in my threaded SSL server application

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Memory leak in my threaded SSL server application

    Yes, I printed a qDebug message on the MessageThread destructor when it is deleted and saw that the destructor is being called.

  2. #2
    Join Date
    Mar 2007
    Posts
    57
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Memory leak in my threaded SSL server application

    And the QTcpSocket/QSslSocket you create in MessageThread, are those deleted? Also, have you tried running with valgrind?

  3. #3
    Join Date
    Mar 2010
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Memory leak in my threaded SSL server application

    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:
    1. m_socket->deleteLater();
    2. m_authTimer->deleteLater();
    To copy to clipboard, switch view to plain text mode 

    to the following code in thread destructor:
    Qt Code:
    1. delete m_socket;
    2. 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

  4. #4
    Join Date
    Feb 2008
    Posts
    50
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Memory leak in my threaded SSL server application

    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.

  5. #5
    Join Date
    Mar 2010
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Memory leak in my threaded SSL server application

    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

  6. #6
    Join Date
    Mar 2010
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Memory leak in my threaded SSL server application

    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:
    1. m_socket->setPrivateKey(":/certs/my-key.pem"); // Add the key that will make the handshake
    2. m_socket->setLocalCertificate(":/certs/my-cert.pem");
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Mar 2010
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Memory leak in my threaded SSL server application

    I think this is the bug reported:
    http://bugreports.qt.nokia.com/browse/QTBUG-6504

Similar Threads

  1. Multi Threaded Client Server application
    By live_07 in forum Qt Programming
    Replies: 0
    Last Post: 27th August 2009, 16:32
  2. Threaded TCP server
    By Sysace in forum Newbie
    Replies: 4
    Last Post: 21st February 2008, 12:37
  3. Threaded server.
    By nithinin2001 in forum Qt Programming
    Replies: 2
    Last Post: 15th November 2007, 16:37
  4. I have memory leak on every Qt3/4 application, Qt bug?
    By saugumas in forum Qt Programming
    Replies: 3
    Last Post: 14th November 2007, 19:33
  5. Memory Leak in my Application :-(
    By Svaths in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2007, 19:42

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.