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

Recursive QTimer:singleshot causes memory leak.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.0.0, 6.0.3
    • Core: Event loop
    • None
    • Windows 7 x64 Ultimate
    • Windows

    Description

      I don't think this is expected behavior since a singleshot should be triggered and then deallocated.

      Steps to reproduce:

      1. Create a new Qt Widgets app.
      2. Create a function slot on MainWindow. Mine is called "executionLoop()"
      3. Call the function slot from the MainWindow constructor.
      4. Put the following code in the function:
      void MainWindow::executionLoop()
      {
          QTimer::singleShot(1, Qt::PreciseTimer, this, SLOT(executionLoop()));
      }

      The process will slowly but steadily use more RAM while never freeing it. executionLoop is called once from outside and only recursively after that, so only one timer should be active at a given time.

      Minimal test project is attached.

      After some more testing, the problem seems to persist up to around a timer of 400 milliseconds, though it's really, really slow. It seems to drop off at about 500 milliseconds.

      This also occurs with a recurring QTimer created and connected from outside the loop and an empty slot function.

      Attachments

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              bcrew1375 Benjamin Crew
              Votes:
              2 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change