Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-17986

Memory leak when QEventLoop is used with an adopted native thread

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 4.8.0
    • 4.8.0
    • Core: Threads
    • None
    • Found on Symbian while testing native thread support. Confirmed to also be a problem on Windows.
    • 0ee221b374ffef3657247be4c78e05689e04bef7

      If you create a QEventLoop within an adopted native thread, the QThreadData, QEventDispatcher and associated objects will not be deleted on thread exit and will leak.

      These conditions occur in the tst_qthread autotest, in the adoptedThreadExec() step.

      The issue seems to be that all QObjects in a thread have a ref on the QThreadData. If these refs are not cleared at thread exit, the QThreadData will never be deleted. In this case, QEventLoop is causing a QEventDispatcher to be created, which normally QThread would clean up on exit. But since the QEventDispatcher exists and refs the QThreadData, the QThread never cleans up so the objects exist forever.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            goffart Olivier Goffart (closed Nokia identity) (Inactive)
            mread Murray Read
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes