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

Recursive QTimer:singleshot causes memory leak.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P1: Critical
    • Resolution: Unresolved
    • Affects Version/s: 6.0.3, 6.0.0
    • Fix Version/s: None
    • Component/s: Core: Event loop
    • Labels:
      None
    • Environment:
      Windows 7 x64 Ultimate
    • Platform/s:
      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

          For Gerrit Dashboard: QTBUG-92912
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              thiago Thiago Macieira
              Reporter:
              bcrew1375 Benjamin Crew
              Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There is 1 open Gerrit change